Create An ArrayList, add some strings and display it.

Output:

*** Create ArrayList ***

[Sadaquat, Ali, Ruk, Geeks, Academy, Hyderabad]

Click Here For Java Online Compiler

Solution:

/**
 *
 * @author Alee Ahmed Kolachi
 */
import java.util.*;

public class CreateArrayList {

    public static void main(String[] args) {
        //creating an arraylist
        List<String> arrayList = new ArrayList();
        System.out.println("*** Create ArrayList ***" + "\n");
        arrayList.add("Sadaquat");
        arrayList.add("Ali");
        arrayList.add("Ruk");
        arrayList.add("Geeks");
        arrayList.add("Academy");
        arrayList.add("Hyderabad");
        System.out.println(arrayList);
    }
}
Share This :

Related Post



sentiment_satisfied Emoticon