工厂方法
来源:互联网 发布:软件著作权申报 编辑:程序博客网 时间:2024/06/05 04:38
要得到一个对象,不用new ,而是通过工厂方法得到目标对象的实例
public class ISample {
}
public class SampleA extends ISample{
}
public class SampleB extends ISample{
}
public class Factory {
public static ISample create(int i){
switch (i) {
case 1:
return new SampleA();
case 2:
return new SampleB();
default:
break;
}
return null;
}
}
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
ISample sample = Factory.create(1);
}
}
0 0
- 工厂与工厂方法
- 工厂模式 -- 工厂方法
- 工厂模式-工厂方法
- 抽象工厂 工厂方法
- 工厂模式-工厂方法
- 工厂 > 工厂方法模式
- 简单工厂,工厂方法
- 工厂方法
- 工厂方法
- 工厂方法
- 工厂方法
- 工厂方法
- 工厂方法
- 工厂方法
- 工厂方法
- 工厂方法
- 工厂方法
- 工厂方法
- JPA-style positional param was not an integral ordinal
- caffe中卷积计算方法
- Leet Code OJ 119. Pascal's Triangle II [Difficulty: Easy]
- 剑指offer 1 二维数组中的查找
- Android 之TextView文本折叠查看显示更多效果
- 工厂方法
- 深入理解HTTP协议(转)http协议学习系列
- android之adapter的抽象与提炼
- react-lifecycle-parent-child.jsx(自github)
- android:layout_gravity="bottom"无效
- 使用CSS实现一个flash动画
- hihoCoder 1038 01背包
- PAM(二)
- SecurityContextHolder.getContext().getAuthentication()为null的问题