Java的abstract关键字

1,抽象是什么意思。

抽象类无法实例化,但可以拥有子类。抽象方法是未实现的声明。

2,源代码

public class Main {

    public static void main(String[] args) {

        // abstract = abstract classes cannot be instantiated, but they can have a subclass
        //            abstract methods are declared without an implementation
        Car car = new Car();
        car.go();
    }
}

由于父类具有抽象属性,无法进行实例化?

public abstract class Vehicle {

    abstract void go();
}

由于亲类中存在抽象方法,因此需要必须重写该方法。

public class Car extends Vehicle {

    @Override
    void go() {
        System.out.println("The driver is driving the car.");
    }
}