【发布时间】:2015-08-14 17:09:44
【问题描述】:
我的问题是—— 如何将 String ArrayList 转换为 Integer ArrayList?
我的号码后面有° EX: 352°。如果我将它们放入 Integer ArrayList,它将无法识别这些数字。为了解决这个问题,我将它们放入一个 String ArrayList 中,然后它们被识别出来。
我想将该字符串数组列表转换回整数数组列表。那么我该如何实现呢?
这是我到目前为止的代码。我想将 ArrayString 转换为 Int Arraylist。
// Read text in txt file.
Scanner ReadFile = new Scanner(new File("F:\\test.txt"));
// Creates an arraylist named ArrayString
ArrayList<String> ArrayString = new ArrayList<String>();
// This will add the text of the txt file to the arraylist.
while (ReadFile.hasNextLine()) {
ArrayString.add(ReadFile.nextLine());
}
ReadFile.close();
// Displays the arraystring.
System.out.println(ArrayString);
提前致谢
迭戈
PS:对不起,如果我不完全清楚,但英语不是我的主要语言。我对 Java 也很陌生。
【问题讨论】: