本帖最后由 kuroro自走核炮 于 2014-4-17 15:24 编辑
- class ExtendsDemo
- {
- public static void main(String[] args)
- {
- Xiali mycar = new Xiali(70,"yello");
- mycar.getColor();
- mycar.getSpeed();
- }
- }
- class Car
- {
- private int speed;
- private String color;
- public Car(int speed,String color)
- {
- this.speed = speed;
- this.color = color;
- }
- public void getColor()
- {
- System.out.println(color);
- }
- public void getSpeed()
- {
- System.out.println(speed);
- }
- }
- class Xiali extends Car
- {
- public Xiali(int speed,String color)
- {
- super(int speed,String color);
- }
- }
复制代码
编译时期的错误提示: D:\java\413>javac YC.javaYC.java:35: 错误: 需要 '.class'
super(int speed,String color);
^
YC.java:35: 错误: 需要';'
super(int speed,String color);
^
YC.java:35: 错误: 需要';'
super(int speed,String color);
^
3 个错误
不太明白这是为什么呢?
|
|