⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 singletontest.java

📁 Spring2.0宝典
💻 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 + -