Java Basic Tutorial
Java Advance Tutorial
An interface in Java is a blueprint of a class that contains abstract methods (methods without a body). Interfaces are used to achieve abstraction and multiple inheritance in Java. It defines a set of methods that a class must implement but does not provide the implementation.
interface InterfaceName { // Abstract method void method1(); // Default method (introduced in Java 8) default void method2() { System.out.println("Default Method"); } // Static method (introduced in Java 8) static void method3() { System.out.println("Static Method"); } }
Try it yourself
Try it yourself
Try it yourself
Try it yourself
Try it yourself