Old (anonymous inner classes)
Runnable meow = new Runnable() {
@Override
public void run() {
System.out.println("meow");
}
};
meow.run();
Output:
meow
Process finished with exit code 0
New.1 (lambda)
Runnable rawr = () -> System.out.println("rawr");
rawr.run();
Output:
rawr
Process finished with exit code 0
New.2 (passing function call)
public static void main(String... args) {
Runnable lalala = Main::LaLaLa;
lalala.run();
}
public static void LaLaLa() {
System.out.println("lalala");
}
Output:
lalala
Process finished with exit code 0
No comments:
Post a Comment