Converting Array to List in Java Program


package com.javatraineronline;

import java.util.Arrays;
import java.util.List;

public class CovertArrayToList {

	public static void main(String[] args) {
		
		// Declaring String Array 
		String[] array = {"One", "Two", "Three", "Four", "Five"};
		
		// Converting Array Object to List Object
		List<String> list = Arrays.asList(array);
		
		// Printing the Converted List Object
		System.out.println("List : "+list);
	}
}

[su_box title=”Output for CovertArrayToList.java”]List : [One, Two, Three, Four, Five]

[/su_box]