Adding java 8 default examples
This commit is contained in:
25
java-8/java-8-default/MyVehicle.java
Normal file
25
java-8/java-8-default/MyVehicle.java
Normal file
@@ -0,0 +1,25 @@
|
||||
interface MyCar {
|
||||
default public String getColor() {
|
||||
return "red";
|
||||
}
|
||||
}
|
||||
|
||||
interface MyBike {
|
||||
default public String getColor() {
|
||||
return "blue";
|
||||
}
|
||||
}
|
||||
|
||||
public class MyVehicle implements MyCar, MyBike {
|
||||
|
||||
public static void main(String args[]) {
|
||||
MyVehicle vehicle = new MyVehicle();
|
||||
System.out.println(vehicle.getColor());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getColor() {
|
||||
return MyCar.super.getColor();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user