我想在文本文件中输出一些数字的总数,并使用 anArrayList
来寻找它们等,我不确定我会怎么做?这是我的代码:
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
public class ArrayListOfNumbers {
public static void main(String[] args) throws FileNotFoundException {
ArrayList<String> numbers = new ArrayList<String>();
Scanner Scan = new Scanner (new File("numbers.txt"));
while (Scan.hasNext()){
numbers.add(Scan.nextLine());
}
for(int i = 0; i < numbers.size(); i++){
System.out.println(numbers.get(i));
}
System.out.println("")
Scan.close();
}
}