Menu

Convert Following Codes Lambda Expressions Old Way Buttonaddactionlistener New Actionliste Q43842975

Convert the following codes into lambda expressions
//Old way:
button.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e){
        System.out.println(“oldfashion code!”);
    }
});

//Old way:
List<Integer> list = Arrays.asList(1,2,3,4,5,6,7);
for(Integer n : list) {
    int x = n * n;
    System.out.println(x);
}

Expert Answer


Answer to Convert the following codes into lambda expressions //Old way: button.addActionListener(new ActionListener() { @Override…

OR