How to convert Array to List in Java ?


This content was proof-read by Grammarly. You can Try Grammary for FREE

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.


Are you a .NET Developer planning to integrate GraphQL for .NET in your Application? Check out this book BUY & DOWNLOAD GRAPHQL.NET COOKBOOK
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);

    }
}
image
%d bloggers like this: