Skip to content

Functional Converter

Carsten Hammer edited this page Feb 19, 2023 · 4 revisions

Before

public static void main(String[] args) {
       new TestDemo().test(Arrays.asList(1, 2, 3));
   }
public void test(List<Integer> ls) {
        for (Integer l : ls)
           System.out.println(l);
   }

After

public static void main(String[] args) {
       new TestDemo().test(Arrays.asList(1, 2, 3));
   }
public void test(List<Integer> ls) {
         ls.forEach(l -> System.out.println(l));
   }