单子模式就是写个单例嘛。无论什么IDE都能写单例的。myeclipse是可以写单例的。
工具类不都是单例的么?怎么可能不能写。

解决方案 »

  1.   

    public class A
    {
          private  static ThreadLocal<A> thread=new ThreadLocal<A>()
          private A()
       {
        }
       public static A getInstance()
      {
           A a=thrad.get();
         if(a==null)
    {
          a=new A();
          thread.set(a);
    }else{
        return a;
    }
        
       }
      
    }
      

  2.   


    package com;public class Test {
        public static void main(String[] args){
         A.getInstanceOfA().show();
        }
    }class A {
    private static A a;
        
        private A(){
        
        }
        
        public static A getInstanceOfA(){
         a=new A();
         return a;
        }
        
        public void show(){
         System.out.println("得到了A的对象,调用了A的方法");
        }
    }