工厂模式代码
package com.bjsunyuhuan.test000;
public class Factory { public static Fruit getInstance(String name){ if("apple".equals(name)){ return new Apple(); }if("orange".equals(name)){ return new Orange(); } return null; } }
总结很重要哦 方法得当,坚持会有奇迹哦