package diamond;

public interface A {

      void doSomething();

}

 

 

package diamond;

public class B implements A {

      @Override

      public void doSomething() {

            System.out.println("Doing something the B way");

      }

}

 

 

 

package diamond;

public class C implements A {

      @Override

      public void doSomething() {

            System.out.println("Doing something the C way");

      }

}

 

 

 

package defaultmethods;

public interface A {

    public default void doSomething() {

        System.out.println("I am A");

    }

}

 

 

 

package defaultmethods;

public class B implements A {

}

 

 

 

package defaultmethods;

 

public class DefaultMethods {

    public static void main(String[] args) {

        B b = new B();

        b.doSomething();

    }

   

}

 

 

 

package defaultmethods;

 

public interface A2 {

    public default void doSomething() {

        System.out.println("I am A2");

    }

}

 

 

 

package defaultmethods;

 

public class B implements A, A2 {

   

}

 

 

 

package defaultmethods;

 

public class B implements A, A2 {

    @Override

    public void doSomething() {

        A2.super.doSomething();

    }

}

 

 

 

package defaultmethods;

 

public interface A {

    public default void doSomething() {

        System.out.println("I am A");

    }

   

    public static void staticMethod() {

        System.out.println("I am a static method");

    }

}