关于java:如何将字符串数组更改为数组。

how to change string array to array. String[] to ArrayList<string> format conversion

本问题已经有最佳答案,请猛点这里访问。

如何将String Array转换为Array List

String[]ArrayList


试试这个:

1
2
String [] strings = new String [] {"stack","overflow" };
List<String> stringList = new ArrayList<String>(Arrays.asList(strings));

你可以做到

  • 使用Arrays.asList()方法

    1
    List<String> list = Arrays.asList(strings);
  • 创建新的ArrayList并复制数组元素(不推荐)

    1
    2
    3
    4
    5
    6
    List<String> list = new ArrayList<String>();

    for (String str : strings)
    {
        list.add(str);
    }

希望这有帮助。


试试这个:

1
2
3
4
5
6
7
8
String[] words = {"ace","boom","crew","dog","eon"};  

List<String> wordList = Arrays.asList(words);  

for (String e : wordList)  
{  
    System.out.println(e);  
}

试试这个

1
2
3
4
5
6
7
private ArrayList<String> list = new ArrayList<String>();
list.clear();

for(int i=0;i<StringArray.length;i++)
{
    list.add(StringArray[i]);
}


试试这个…

1
2
3
4
5
6
String[] arr = {"40","50","60","70","80","90","100", };

ArrayList<String> arr_list = new ArrayList<String>();

for (int i = 0; i < arr.length; i++)
    arr_list.add(arr[i]);

1
ArrayList<String> arr_list = new ArrayList<String>(Arrays.asList(arr));