私はテキストファイルから読み込みしようとしており、リストを使って繰り返しのない行だけを出力しようとしています。テキストファイルからのJavaの読み込み
File file = new File("E:/......Names.txt");
List<String> names = new ArrayList<String>();
Scanner scan = new Scanner(file);
int j=1;
while(scan.hasNextLine() && j!=100){
if(!names.contains(scan.nextLine()))
names.add(scan.nextLine());
System.out.println(names);
j++;
}
scan.close();