package com.conpany.iterator;
//多态 工人赚钱
interface Money{
public void MakeMoney();
}
class Worker implements Money{
@Override
public void MakeMoney() {
System.out.println("工人赚钱");
}
}
public class Demo1 {
public static void main(String[] args) {
Money m=test();//父类接口 指向子类方法 因为返回的是 实现类的方法 有一个子类的对象
m.MakeMoney();
}
public static Worker test(){//子类静态方法 实现子类
return new Worker();
}
//多态 工人赚钱
interface Money{
public void MakeMoney();
}
class Worker implements Money{
@Override
public void MakeMoney() {
System.out.println("工人赚钱");
}
}
public class Demo1 {
public static void main(String[] args) {
Money m=test();//父类接口 指向子类方法 因为返回的是 实现类的方法 有一个子类的对象
m.MakeMoney();
}
public static Worker test(){//子类静态方法 实现子类
return new Worker();
}
}