java interface constructor 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: constructor in java
public class ConstructorDemo
{
int a;
ConstructorDemo()
{
a = 26;
}
public static void main(String[] args)
{
ConstructorDemo obj = new ConstructorDemo();
System.out.println(obj.a);
}
}