is it possible to make a method Static in Interface ? if yes then how to call that method form interface ?
yes... from version 1.8 it is available but up to 1.7 interfaces support only abstract methods..
if you declared static method in interface it distrub to all interface impleamented class...follow this code
package youthforwork;
public interface Youth {
void run();
static void test()
{
System.out.println(" we can declare static method ");
}
default void test1()
{
System.out.println("but it is available from 1.8 only");
}
}
package youthforwork;
public class Implemented implements Youth {
public void run()
{
System.out.println(" executing / calling interface (STATIC) method in implemented class");
}
public static void main(String[] args) {
Youth y=new Implemented();
y.run();
y.test1();
Youth.test();
}
}
EXECUTE THIS CODE