Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Java List

// Java Program to illustrate the
// addition of elements in a List
 
import java.util.*;
public class GFG {
 
    public static void main(String args[])
    {
 
        // Creating a List
        List<String> al = new ArrayList<>();
 
        // Adding elements in the List
        al.add("mango");
        al.add("orange");
        al.add("Grapes");
 
        // Iterating the List
        // element using for-each loop
        for (String fruit : al)
            System.out.println(fruit);
    }
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #Java #List
ADD COMMENT
Topic
Name
4+9 =