method in interface 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: java interface
public interface Exampleinterface {
public void menthod1();
public int method2();
}
class ExampleInterfaceImpl implements ExampleInterface {
public void method1()
{
//code here
}
public int method2()
{
//code here
}
}