//静态代码块 class test16 { private static final String URL ; private static final String DEVICE ; private static final String USER ; private static final String ROOT ; static test16 self ; static { URL = "歌谣" ; DEVICE = "笔记本电
//静态代码块
class test16 {
private static final String URL;
private static final String DEVICE;
private static final String USER;
private static final String ROOT;
static test16 self;
static {
URL="歌谣";
DEVICE="笔记本电脑";
USER="root";
ROOT="歌谣";
if(self==null){
self=new test16();
}
}
public static String getURL() {
return URL;
}
public static String getDEVICE() {
return DEVICE;
}
public static String getUSER() {
return USER;
}
public static String getROOT() {
return ROOT;
}
public test16(){
}
}
定义一个测试类public class test17 {
public static void main(String[] args){
System.out.println(test16.getDEVICE());
}
}
运行结果