2015年9月21日 星期一

Java 介面的繼承


public interface Boats {
    public void launch();
}

public interface MotorizedBoat extends Boats{
    public void start();
}

public interface Car {
    public void start();
}

public class BasicCar implements Car{

    @Override
    public void start() {
        Engine e1 = new Engine(){
            public String start(){
                return ("Engine is :" + start());
            }
        };
    }

    private static class Engine {
        public String start(){
            return "Starting ....";
        }
    }  
}

public class AmphibiousCar extends BasicCar implements MotorizedBoat , java.io.Serializable{

    @Override
    public void launch() {
        System.out.println("要行駛了....");
    }   
}