请问一下我这个作业有啥问题吗?
这是我在Notepad++上打得代码。。。
public class Transport { public void manned() { System.out.println("Transport can Manned"); } } public class Bus extends Transport { public void manned() { System.out.println("Bus = 40"); } } public class Ship extends Transport { public void manned() { System.out.println("Ship = 200"); } } public class Plane extends Transport { public void manned() { System.out.println("Plane = XXX"); } } public class Initail { public static void main(String[] args) { Transport bus = new Bus(); Transport ship = new Ship(); Transport plane = new Plane(); bus.manned(); ship.manned(); plane.manned(); } }
在CMD中编译出现:
H:\>javac Transport\Initail.java
Transport\Initail.java:1: 错误: 类 Transport 是公共的, 应在名为 Transport.java 的文件中声明
public class Transport {
^
Transport\Initail.java:7: 错误: 类 Bus 是公共的, 应在名为 Bus.java 的文件中声明
public class Bus extends Transport {
^
Transport\Initail.java:13: 错误: 类 Ship 是公共的, 应在名为 Ship.java 的文件中声明
public class Ship extends Transport {
^
Transport\Initail.java:19: 错误: 类 Plane 是公共的, 应在名为 Plane.java 的文件中声明
public class Plane extends Transport {
^
请教一下各位!!!感谢!