public abstract class Bank { public void ticket() { System.out.println("排队取号"); } public abstract void manageMoney(); public void giveMark() { System.out.println("给客服评分"); } public final void process(){ this.ticket(); this.manageMoney(); this.giveMark(); } }
public class Client { public static void main(String[] args) { Bank bank1 = new Bank() { @Override public void manageMoney() { System.out.println("我要理财"); } }; bank1.process(); System.out.println("------------------"); Bank bank2 = new Bank() { @Override public void manageMoney() { System.out.println("我有2000万,需要转账"); } }; bank2.process(); } } /*class person extends Bank{ @Override public void manageMoney() { System.out.println("我要理财"); } } class person2 extends Bank{ @Override public void manageMoney() { System.out.println("我有2000万,需要转账"); } }*/