Ни один включающий экземпляр недоступен. Необходимо квалифицировать выделение с помощью включающего экземпляра типа (например, x.new A(), где x — это экземпляр )",
с помощью этого кода:
Код: Выделить всё
package moreAboutOOP;
public class Inheritance {
public class Vehicle {
protected String licensePlate = null;
public void setLicensePlate(String license) {
this.licensePlate = license;
}
}
public class Car extends Vehicle {
int numberOfSeats = 0;
public int getNumberOfSeats() {
return (this.numberOfSeats);
}
public String getLicensePlate() {
return this.licensePlate;
}
}
public static void main(String[] args) {
Vehicle v1 = new Vehicle();
v1.setLicensePlate("P125ADS");
Car c1 = new Car();
c1.setLicensePlate("P124ABS");
System.out.println("");
}
}