为什么我写的好像会提示方法没有创建?
package com.Traffic; public class Plane extends Trasportation { public void methods(){ int num=200; System.out.println("飞机可以在空中载"+num+"人"); } } package com.Traffic; public class Buss extends Trasportation { public void methods(){ int num=60; System.out.println("汽车可以在路上载"+num+"人"); } }
package com.Traffic;
public class Ship extends Trasportation {
public void methods(){
int num=300;
System.out.println("轮船可以在海上载"+num+"人");
}
}
package com.Traffic;
public class Trasportation {
public static void main(String[] args) {
Trasportation obj1=new Trasportation();
Trasportation obj2=new Ship();
Trasportation obj3=new Plane();
Trasportation obj4=new Buss();
obj3.methods();
obj2.methods();
obj4.methods();
}
}