teststatic.java
来自「我自己学习JAVA过程中用键盘敲的代码」· Java 代码 · 共 32 行
JAVA
32 行
package jerryhfb;
public class TestStatic{
public int instanceInteger=0;
public int instanceMethod(){
return instanceInteger;
}
public static int classInteger=0;
public static int classMethod(){
return classInteger;
}
public static void main(String[] args){
TestStatic anInstance=new TestStatic();
TestStatic anotherInstance=new TestStatic();
anInstance.instanceInteger=1;
anotherInstance.instanceInteger=2;
System.out.println(anInstance.instanceMethod());
System.out.println(anotherInstance.instanceMethod());
TestStatic.classInteger=7;
System.out.println(classMethod());
System.out.println(anInstance.classMethod());
System.out.println(anotherInstance.classMethod());
anInstance.classInteger=9;
System.out.println(anInstance.classMethod());
System.out.println(anotherInstance.classMethod());
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?