【Java基礎】將數組轉換爲List或者LinkedList

將數組轉換爲List:

String[] ids = proHist.split("#");
//將ids轉化爲list集合
Collection<String> collection = Arrays.asList(ids);

將List轉換爲LinkedList:

LinkedList<String> list = new LinkedList<>(collection);

將LinkedList轉換爲String

//將linkedlist轉換爲string
StringBuffer sBuffer=new StringBuffer();
    for (String string : list) {
        sBuffer.append(string);
    }
String result = sBuffer.toString();
result=result.substring(0, result.length());
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章