interface InterfaceA
{
default void sayHello()
{
System.out.println("default Hello by InterfaceA...");
}
}
InterfaceB.java public interface InterfaceB
{
default void sayHello()
{
System.out.println("default Hello by InterfaceB...");
}
}
MyClass.java public class MyClass implements InterfaceA,InterfaceB
{
public void sayHello()
{
System.out.println("Hello by myclass...");
}
}
InterfaceTest.java public class InterfaceTest
{
public static void main(String[] args)
{
InterfaceA interfaceARef = new MyClass();
interfaceARef.sayHello();
System.out.println("----------------------");
InterfaceB interfaceBRef = new MyClass();
interfaceBRef.sayHello();
}
}