❮ Previous Next ❯

Interface in java 8

Java 8(JDK 1.8 version) introduces a new concept of default method and static method implementation in interface. We can define method inside interface using the keyword default and static.

Java interface default method

To define a default method in java interface, we use “default” keyword with the method signature.

For example,

package test;
interface A{
default void show()
{
          System.out.println("Silan Technology");
}
}
class B implements A
{
         

}

class InterfaceExample
{
public static void main(String[] args)
{
B obj=new B();
obj.show();
}
}

Output

Silan Technology

Java interface static method

package test;
interface I{
static void show()
{
System.out.println("Silan Technology");
}
}

class InterfaceExample1
{
public static void main(String[] args)
{
A.show();
}
}

Output

Silan Technology

❮ Previous Next ❯



  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved