Open In App

Evolution of interface in Java

Prerequisite : Interfaces in Java
In Java SE 7 or earlier versions, an interface can have only:

We can’t provide implementations of methods in interfaces.




public interface GFG{
      String a = "Geeksforgeeks is the best.";
      
      void hello(String a);
      void world(int x);
}

Java SE 8:
We can write method implementations in Interface from Java SE 8 and on-wards. We need to use “default” keyword to define them as shown below.
In Java SE 8 and later versions, an interface can have only four kinds of things:

Article Tags :