?? staticdemo1.java
字號:
class StaticDemo1{
static int x=10;
int y=20;
static void show(){
System.out.println("static method output: static int x= "+ x);
}
static void show( int x){//static不能掉
System.out.println("method output: "+x);
}
public static void main(String args[]){
show();
x+=100;show(555);//靜態(tài)方法中只能操作靜態(tài)變量,若出現(xiàn) y+=99999;就錯了
System.out.println("x changed. x="+x+"\n");
StaticDemo1 object=new StaticDemo1();
object.show();//這里創(chuàng)建對象了。
object.x+=1000;
object.y+=9900;
System.out.println("static int x="+StaticDemo1.x);
System.out.println("static int x="+object.x);
System.out.println("int y="+object.y);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -