public class Person {
//单例模式
private static Person person = new Person();
public static Person getInstance(){
return person;
}
public static void main(String[] args) {
//单利模式
Person p1 = Person.getInstance();
Person p2 = Person.getInstance();
System.out.println(p1==p2);
//main方法参数的意义 他是编译时传递的类参数 这个方法是有虚拟机调用的
args=new String[3];
args[0] = "lll";
System.out.println(args[0]);
}
}
打印结果:
true
lll