Problem Description: We need to extract a common method used to resolve duplicate code between the two default methodological issues
But this total approach should not be allowed to use the implementation class, it should be privatized;
Solution: Define private methods
1 ordinary private methods: Repeat the code to solve the problems between multiple default method
format:
Replace the value type method private name (parameter list) {
// method body
}
2 static methods: resolve duplicate code across multiple static method problem
Format: private static method return type name (parameter list) {
// method body
}
public interface MyInterface{
private default void methodDefault1()
{
System.out.println();
methodCommen();
}
private default void methodDefault2()
{
System.out.println();
methodCommen();
}
}