// Interface interface Printable { void print(); } // Class implementing the interface class Printer implements Printable { @Override public void print() { System.out.println("Printing..."); } } public class InterfaceExample { public static void main(String[] args) { // Creating an instance of the class implementing the interface Printable printer = new Printer(); // Using the interface method printer.print(); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter