Java Arrays convert array to List

Description

Java Arrays convert array to List


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

public class Main {
    /*from w w w.  j a v  a 2 s  .co  m*/
    public static void main(String[] args) {
        String[] cars = {"HTML", "CSS", "css", "demo2s.com"};
        List<String> carList = Arrays.asList(cars);
 
        for (String car : carList) {
            System.out.println(car);
        }
    }
}



PreviousNext

Related