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.
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:
- Constant variables
- Abstract methods
- Default methods
- Static methods
- Constant variables
- Abstract methods
- Default methods
- Static methods
- Private methods
- Private Static methods
- Java.util.function.BiPredicate interface in Java with Examples
- Java.util.function.IntPredicate interface in Java with Examples
- Java.util.function.LongPredicate interface in Java with Examples
- Java.util.function.DoublePredicate interface in Java with Examples
- Map Interface in Java
- Java 8 | DoubleToLongFunction Interface in Java with Examples
- Java 8 | IntToDoubleFunction Interface in Java with Examples
- Java 8 | Consumer Interface in Java with Examples
- Java 8 | BiConsumer Interface in Java with Examples
- UnaryOperator Interface in Java
- Map.Entry interface in Java with example
- ConcurrentMap Interface in java
- Queue Interface In Java
- Java 8 | ObjIntConsumer Interface with Example
- Java 8 | ObjDoubleConsumer Interface with Example
public interface GFG{ String b = "Shubham is a brilliant coder."; default void hello(String a){ System.out.println("Hello"); } static void world(int x){ System.out.println("World"); } void bye(); } |
Java SE 9:
In Java SE 9 and on-wards, we can write private methods in Interfaces using ‘private’ access modifier as shown below (like other private methods).
In Java SE 9 and later versions, an interface can have:
public interface GFG{ String b = "Shubham is a brilliant coder."; default void hello(String a){ System.out.println("Hello"); } static void world(int x){ System.out.println("World"); } void bye(); private void great(long v){ } } |
This article is contributed by Shubham Juneja. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.



