convert array object to list object - Java

array to list

Snippet Code


  
Rate this page :
  [ 0 votes]

Use this code to convert a array into a list object.

public class Main { public void arrayToList() { String[] cars = {"Fiat", "Chevrolet", "BMW", "Toyota"}; List<String> carList = Arrays.asList(cars); for (String car : carList) { System.out.println(car); } } public static void main(String[] args) { new Main().arrayToList(); } }

Tags


Ask Questions

Ask Question