October 2018
Intermediate to advanced
192 pages
5h 12m
English
Up until Java 1.7, it was not possible to define a method inside an interface. Now, 1.8 introduces the default methods through which we can provide implementation for a method inside the interface. Let's see an example of this here:
interface Phone{ void dial(); default void text() { System.out.println("Texting a message"); }}
Static methods in Java are those methods that can be invoked without creating an object of a particular class, provided that the static method is in that particular class. In Java 8, static methods can be defined inside an interface, as shown here:
interface Phone { inx x; void changeRingtone(); static void text() { System.out.println("Texting"); }}public class PhoneDemo { ...Read now
Unlock full access