「java入門」interfaceのdefault実装コード

javaコード
public class DemoClass implements InterfaceA, InterfaceB {
public static void main(String[] args){
DemoClass cft = new DemoClass();
cft.sayHello();
}

@Override
public void saySomething() {
// TODO Auto-generated method stub
}

@Override
public void sayHello(){
System.out.println(“implemetation of sayHello() in DemoClass");
}
}
interface InterfaceA{
public void saySomething();
default public void sayHello(){
System.out.println(“Hi from InterfaceA");
}
}
interface InterfaceB{
default public void sayHello(){
System.out.println(“Hi from InterfaceB");
}
}

Java

Posted by arkgame