As you, specialists, know in Java 8, interfaces can have static methods which have implementations inside themselves.
As I have read in a related tutorial, the classes which implement such interface can use its static methods. But, I have a problem which, here, I show it in a simpler example than what I have
public interface Interface1{
public static void printName(){
System.out.println("Interface1");
}
}
when I implement such interface
public class Class1 implements Interface1{
public void doSomeThing() {
printName();
}
}
I encounter compile error.
The method printName() is undefined for the type Class1
What's the problem?
Interface1.printName();
). If the tutorial suggested the above should work, though, it's simply wrong.