Java - Use List forEach method to output its content

Description

Use List forEach method to output its content

Demo

import java.util.Arrays;
import java.util.List;

public class SimpleMain {
  public static void main(String[] args) {
    List<String> lst = Arrays.asList("Aman", "varun", "Sonu");
    lst.forEach(p -> System.out.println(p));
    System.out.println("As same Arguments");
    lst.forEach(System.out::println);
  }//from   w ww  .j ava  2  s. c  o  m
}

Related Topic