Check out example codes for "geeks for geeks java interfaces". It will help you in understanding the concepts better.

Code Example 1

// Assume we have the simple interface:
interface Appendable {
	void append(string content);
}
// We can implement it like that:
class SimplePrinter implements Appendable {
 	public void append(string content) {
   		System.out.println(content); 
    }
}
// ... and maybe like that:
class FileWriter implements Appendable {
 	public void append(string content) {
   		// Appends content into a file 
    }
}
// Both classes are Appendable.
0
how to implement a interface in java

Code Example 2

// Java program to demonstrate working of  
// interface. 
import java.io.*; 
  
// A simple interface 
interface In1 
{ 
    // public, static and final 
    final int a = 10; 
  
    // public and abstract  
    void display(); 
} 
  
// A class that implements the interface. 
class TestClass implements In1 
{ 
    // Implementing the capabilities of 
    // interface. 
    public void display() 
    { 
        System.out.println("Geek"); 
    } 
  
    // Driver Code 
    public static void main (String[] args) 
    { 
        TestClass t = new TestClass(); 
        t.display(); 
        System.out.println(a); 
    } 
}

Code Example 3

// Assume we have the simple interface:
interface Appendable {
	void append(string content);
}
// We can implement it like that:
class SimplePrinter implements Appendable {
 	public void append(string content) {
   		System.out.println(content); 
    }
}
// ... and maybe like that:
class FileWriter implements Appendable {
 	public void append(string content) {
   		// Appends content into a file 
    }
}
// Both classes are Appendable.

Learn ReactJs, React Native from akashmittal.com