-4
爲什麼我得到一個NullPointerException當我試試這個:轉換的ArrayList <Long>到ArrayList的<String>與循環
ArrayList<String> longsToStrings() throws IOException {
LinkedList<Long> longNumbers = populateArrayWithLongs();
ArrayList<String> strings = null;
for (Long l : longNumbers) {
strings.add(l.toString());
}
return strings;
}
當我嘗試打印結果到控制檯,我得到NullPointerException異常。 populateArrayWithLongs()函數返回數組渴望:1488758722000,1488773070000,1488787530000,1488801890000]
謝謝!這就像魅力:) –