摘要:
CentOS7搭建Kafka单机环境及基础操作 前提 安装Kafka前需要先安装zookeeper集群 Kafka安装 解压 tar -zxvf kafka_2.8.0-0.8.0.tar.gz 修改配置 cd /usr/local/hadoop/kafka_2.8.0-0.8.0/config v 阅读全文
interface food{}
class A implements food{}
class B implements food{}
class C implements food{}
public class StaticFactory {
private StaticFactory(){}
public static food getA(){ return new A(); }
public static food getB(){ return new B(); }
public static food getC(){ return new C(); }
}
class Client{
//客户端代码只需要将相应的参数传入即可得到对象
//用户不需要了解工厂类内部的逻辑。
public void get(String name){
food x = null ;
if ( name.equals("A")) {
x = StaticFactory.getA();
}else if ( name.equals("B")){
x = StaticFactory.getB();
}else {
x = StaticFactory.getC();
}
}
}