📄 singletontest.java
字号:
/*******************************************************************
<br>Copyright (C), 2004-2006, yeeku.H.Lee
<br>Program Name:SingletonTest
<br>Author:yeeku.H.lee kongyeeku@163.com
<br>Version:1.0
<br>This program is protected by copyright laws.
<br>Date: 2005-10-2
*******************************************************************/
public class SingletonTest
{
int value ;
private static SingletonTest instance;
private SingletonTest()
{
}
public static SingletonTest getInstance()
{
if (instance == null)
{
instance = new SingletonTest();
}
return instance;
}
public int getValue()
{
return value;
}
public void setValue()
{
value = 9;
}
public static void main(String[] args)
{
SingletonTest t1 = getInstance();
System.out.println(t1.getValue());
SingletonTest t2 = getInstance();
t2.setValue();
System.out.println(t1.getValue());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -