This article will explain how to convert a simple array to list in Java .
How to convert Array to List in Java ?
The Java’s array class provides necessary methods to convert the array to the List using the asList method. Below is a sample code snippet demonstrating the usage of the Arrays.asList method to convert array to List.
package com.abundantcode;
import java.util.Arrays;
import java.util.List;
public class Main {
public static void main(String[] args)
{
String[] input = {"Java", "Abundantcode.com", "MCA Lab Programs", "B.E Java Lab Programs", "BCA Java Programs"};
List<String> stringLst = Arrays.asList(input);
System.out.println(stringLst);
}
}
1 Comment