how is an interface used in java code example

Example 1: how to implement a interface in java

interface methods{
 public static hey(); 
}

class scratch implements methods{
  // Required to implement all methods declared in an interface 
  // Or else the class becomes abstract
  public static hey(){
   System.out.println("Hey"); 
  }
}

Example 2: Interface in java

// interface syntax
interface InterfaceName
{
   fields // by default interface fields are public, static final
   methods // by default interface methods are abstract, public
}