April 2018
Intermediate to advanced
910 pages
33h 21m
English
Lambda expressions were a big part of the Java 8 release. As a follow-up to that improvement, private methods in interfaces are now feasible. Previously, we could not share data between non-abstract methods of an interface. With Java 9, this data sharing is possible. Interface methods can now be private. Let's look at some sample code.
This first code snippet is how we might code an interface in Java 8:
. . . public interface characterTravel { pubic default void walk() { Scanner scanner = new Scanner(System.in); System.out.println("Enter desired pacing: "); int p = scanner.nextInt(); p = p +1; } public default void run() { Scanner scanner = new Scanner(System.in); System.out.println("Enter desired ...