日期:2014-05-20 浏览次数:20770 次
class singleton { private singleton() {} public static singleton getInstance = new singleton(); }
------解决方案--------------------
帮顶 楼主万岁 嘿嘿、
------解决方案--------------------
接分来的
------解决方案--------------------
看出来了。。。纯散分的~
------解决方案--------------------
帮顶,LZ好人,多给点哈
------解决方案--------------------
纯散分的
------解决方案--------------------
路过 顺便接个分 (*^__^*) 嘻嘻……
谢谢楼主
------解决方案--------------------
迭代器模式
foreach(var item in (new List<int>(){ 1 , 2 , 3 })) { Console.WriteLine(item); }
------解决方案--------------------
简单工厂...
路过。
------解决方案--------------------
简单抽象工厂
------解决方案--------------------
工厂模式
public class DaoFactory {
private static UserDao userDao = null;
private static DaoFactory instance = new DaoFactory();
private DaoFactory() {
try {
Properties prop = new Properties();
InputStream inStream = DaoFactory.class.getClassLoader()
.getResourceAsStream("daoconfig.properties");
prop.load(inStream);
String userDaoClass = prop.getProperty("userDaoClass");
Class clazz = Class.forName(userDaoClass);
userDao = (UserDao) clazz.newInstance();
} catch (Throwable e) {
throw new ExceptionInInitializerError(e);
}
}
public static DaoFactory getInstance() {
return instance;
}
public UserDao getUserDao() {
return userDao;
}
}
------解决方案--------------------
观察者模式
public class Button { public event EventHandler Click; }
------解决方案--------------------
单态模式
private static singlet instance=new singlet();
public static singlet getinstance{
return instance;}
------解决方案--------------------