dcsimg
LinkedIn
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
May 11, 2021

Default Methods in Java Interfaces

Prior to Java 8, interfaces in Java typically did not have any definitions. That changed starting with Java 8, where defining interface methids was made possible. There are are multiple reasons why you would want to add a definition to your Java methods. Below, we demonstrate how to define a default method in Java interfaces.

*/


public interface DefaultMethodInterface {

	default void print() {
		System.out.println("I am the default method in the interface!");
	}
	
}	
MS Sridhar
 
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date