package zhangsan.lisi;
//STSTIC用法1
class Apointer{
public static int aNumber = 100;//这里不加static 下面主函数中将不能直接对类A直接使用
public static void funShion(){//这里也是同样的,必须加上Static下面才可以直接调用
System.out.printf("2012-3-7 9:06:05");
}
public void f(){
funShion();//非静态变量可以访问静态变量,因为静态变量是跟随类产生就可以使用的
System.out.println("GGGG");
}
}
public class ThisPointer {
public static void main(String [] args){
System.out.print(Apointer.aNumber+"\n");
//Apointer.funShion();因为funShion是静态的,直接可以使用类名访问
Apointer aa = new Apointer();
aa.f();
}
}
//STSTIC用法1
class Apointer{
public static int aNumber = 100;//这里不加static 下面主函数中将不能直接对类A直接使用
public static void funShion(){//这里也是同样的,必须加上Static下面才可以直接调用
System.out.printf("2012-3-7 9:06:05");
}
public void f(){
funShion();//非静态变量可以访问静态变量,因为静态变量是跟随类产生就可以使用的
System.out.println("GGGG");
}
}
public class ThisPointer {
public static void main(String [] args){
System.out.print(Apointer.aNumber+"\n");
//Apointer.funShion();因为funShion是静态的,直接可以使用类名访问
Apointer aa = new Apointer();
aa.f();
}
}

1万+

被折叠的 条评论
为什么被折叠?



