package com.shrimpking.t6;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/9/16 14:51
*/
class Person6{
String name;
private static final Person6 PERSON = new Person6();
private Person6(){
this.name = "NoName";
}
public static Person6 getInstance(){
return PERSON;
}
}
public class TestSingleDemo
{
public static void main(String[] args)
{
//单例
Person6 p;
p = Person6.getInstance();
System.out.println("姓名=" + p.name);
}
}


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



