Static methods in java interface – Java 8
Till java 7 static methods not supported by interface. But in java 8 we can declare static methods in interface.
Example Code
Car.java (Interface)
public interface Car { public static void printCarId(){ System.out.println("23079834"); } }
Here in above code we have one interface Car with one static method printCarId();.
Note :
1. Static methods must declare with body means we can not use abstract keyword with static methods.
2. Static methods cannot be overridden.