RE: RE: [Programming][Java][Guide] Using Lambda Expressions In Java [Part 1]
You are viewing a single comment's thread from:

RE: [Programming][Java][Guide] Using Lambda Expressions In Java [Part 1]

Words
19
Reading
1 min
9y

Can I use the lambda everytime I would pass an object that implements an interface?
Like the example below:

JButton button = new JButton();
// Without Lambda
button.addActionListener(new ActionListener() {

    @Override
    public void actionPerformed(ActionEvent e) {
        System.out.println("Doing something.");
    }
});
// With Lambda
button.addActionListener(e -> {
    System.out.println("Doing something.");
});
@icebaer: Can I use the | Ecency