看看我的。指教一下啊
package likun.yi; public class Vehicle { public void payload() { System.out.println( "载客" ); }} |
1 | package likun.yi; public class Bus extends Vehicle { public void payload() { System.out.println( "载客40人" ); }} |
1 | package likun.yi; public class Ship extends Vehicle { public void payload() { System.out.println( "载客150人" ); }} |
1 | package likun.yi; public class Plane extends Vehicle { public void payload() { System.out.println( "载客300人" ); }} |
1 | package likun.yi; public class Init { public static void main(String[] args) { // TODO Auto-generated method stub Vehicle bus = new Bus(); bus.payload(); Vehicle ship = new Ship(); ship.payload(); Vehicle plane = new Plane(); plane.payload(); }} |
载客40人
载客150人
载客300人