单例

来源:互联网 发布:网络测线器的使用方法 编辑:程序博客网 时间:2024/04/30 11:32
package com.cavaness.quartzbook.chapter3;public class Test {private static Test test = new Test();private Test() {}public static Test getInstance() {return test;}public void method() {System.out.println("I am the method of Test!");}}class Test2 {public static void main(String[] args) {Test.getInstance().method();}}