Evolution of interface in Java

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

  • Constant variables
  • Abstract methods

We can’t provide implementations of methods in interfaces.

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


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: