How to loop through objects in java using streams

Java
ArrayList<String> namesList = new ArrayList<String>(Arrays.asList( "alex", "brian", "charles") );
         
namesList.forEach(name -> System.out.println(name));

Source

Also in Java: