Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java foreach arraylist

// Java Program Demonstrate forEach()
// method of ArrayList
  
import java.util.*;
public class GFG {
  
    public static void main(String[] args)
    {
        // create an ArrayList which going to
        // contains a list of Numbers
        ArrayList<Integer> Numbers = new ArrayList<Integer>();
  
        // Add Number to list
        Numbers.add(23);
        Numbers.add(32);
        Numbers.add(45);
        Numbers.add(63);
  
        // forEach method of ArrayList and
        // print numbers
        Numbers.forEach((n) -> System.out.println(n));
    }
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #java #foreach #arraylist
ADD COMMENT
Topic
Name
1+3 =