Convert Array To ArrayList | Java Programs

Output:

*** Convert Array to ArrayList ***

Converted to ArrayList: 
[Alee, Ahmed, Shakoor, Umar, Anwar, Jawad]

Click Here For Java Online Compiler

Solution:

import java.util.ArrayList;
import java.util.Arrays;

public class ConvertArrayToArrayList {

    public static void main(String[] args) {
        String[] array = new String[]{"Alee", "Ahmed", "Shakoor", "Umar", "Anwar", "Jawad"};
        ArrayList<String> list = new ArrayList<String>(Arrays.asList(array));
        System.out.println("*** Convert Array to ArrayList ***" + "\n");
        System.out.println("Converted to ArrayList: ");
        System.out.println(list);
    }
}
Share This :

Related Post



sentiment_satisfied Emoticon