interface Fruit(){
public void eat();
}
class Apple implements Fruit(){
public void eat(){
System.out.println("吃苹果");
}
class Orange implements Fruit(){
public void eat(){
System.out.println("吃橘子");
}
class Factory(){
public static Fruit getInstance(String className){
if("apple".equals(calssName)){
return new Apple
}else{return new Orange}}
public class TestDemo{
public static void main(String args[]){
Fruit f=Factory.getInstance("apple");
f.eat();
}}
}