June 2018
Intermediate to advanced
280 pages
7h 46m
English
The observer pattern got replaced in Java 8 with lambda expressions. The most obvious example is the ActionListener replacement. The old code, using anonymous class listeners, got replaced with a simple function call:
JButton button = new Jbutton("Click Here");button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Handled by the old listener"); }});
The new code is just one line:
button.addActionListener(e -> System.out.println("Handled by lambda"));
Read now
Unlock full access