在main中无法创建类的对象

public class TestOverride {
public static void main(String[] args) {
Vehicle v1=new Vehicle();// 此处无法创建对象,编译器报错
Vehicle v2=new Horse();
Vehicle v3=new Plane();

    v1.run();
    v2.run();
    v3.run();
    v2.stop();
    v3.stop();
}

class Vehicle{//交通工具类
    public void run() {
        System.out.println("跑");
    }

    public void stop() {
        System.out.println("停");
    }
}

class Horse extends Vehicle{//马也是交通工具
    public void run() {//重写父类方法
        System.out.println("四蹄翻飞 ..");
    }
}

class Plane extends Vehicle{
    public void run() {//重写父类方法
        System.out.println("飞上天..");
    }
    public void stop() {
        System.out.println("空中不能停...");
    }
}

}



Vehicle v1=new Vehicle();
->
Vehicle v1=new TestOverride(). new Vehicle();
别的类似

或者把

class Vehicle{//交通工具类
    public void run() {
        System.out.println("跑");
    }

    public void stop() {
        System.out.println("停");
    }
}

class Horse extends Vehicle{//马也是交通工具
    public void run() {//重写父类方法
        System.out.println("四蹄翻飞 ..");
    }
}

class Plane extends Vehicle{
    public void run() {//重写父类方法
        System.out.println("飞上天..");
    }
    public void stop() {
        System.out.println("空中不能停...");
    }
}

放在
public class TestOverride {
...
}
外面
<-也就是这里

问题解决的话,请点采纳