Java Interface Static Method - JDK8

Java Interface static method is similar to default method except that we can't override them in the implementation classes.
We can safely add them to existing interfaces without changing implementation classes.
Since static method don't belong to particular object, they are not part of API of classes implementing the interface and they have to be called by interface name( preceding the method name).
  • Java interface static methods are good for providing utility methods.
  • Static methods in interfaces make possible to group related utility methods without having to create artificial utility classes that are simply placeholders for static methods.

Difference between Defalut and Static Methods

  1. Default methods can be overriden in implementing class. Where as static methods cannot be overriden.
  2. Static methods belongs only to Interface class, so you can only invoke static methods or an interface class, not on class.
  3. Both class and interface can have static methods with same names & neither overrides other.
  4. default methods are Visible/usable in Object interface scope.

About the Author
Rajesh K. Bansal (SCJP-Sun Certified Java Programmer)
20 Years experience in Training & Development. Founder of realJavaOnline.com, loves coding in Java(J2SE, J2EE), C++,PHP, Python, AngularJS, Android,MERN Stack(MongoDB,Express,ReactJS,NodeJS). If you like tutorials and want to know more in depth about Java , buy his book "Real Java" available on amazon.in.
#Email : bcebti@gmail.com #Contact : 98722-46056
Available on Amazon
Card image cap
Under the guidance of Founder & Author of "realJavaOnline.com". M:9872246056
Card image cap