JAVA static解析

来源:互联网 发布:淘宝开店ppt 编辑:程序博客网 时间:2024/06/01 09:22
package d1;
import java.io.File;


public class file1 {


public static void main(String[] args) {
test();}
static void test(){
String path ="c:\\java";
String file="hell.java";
File f=new File(path,file);
test2();
try{
boolean b=f.createNewFile();
System.out.println(b);

}catch(Exception e){
e.printStackTrace();
}




}
static  void test2(){int a=9;}

}


其中test方法直接访问test2();static没有this或者super()

super()表示调用父类构造函数

this相当于一个构造函数

0 0
原创粉丝点击