提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
将字符串数组转换为列表
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; /** 来自 时代Java - N o w J a v a . c o m**/ public class Main { public static void main(String args[]) { String[] numbers = new String[] { "one", "two", "three","nowjava.com" }; List list = (List) Arrays.asList(numbers); System.out.println("String array converted to List"); for (int i = 0; i < list.size(); i++) { System.out.println(list.get(i)); /* 来自 *N o w J a v a . c o m*/