Ciao sto imparando da poco java e non riesco a risolvere un problema: stampare le parole di un file di txt da terminale,usando l'interfaccia List.
Il programma che ho sviluppato è:
codice:
import java.util.*;
import java.io.*;
class ListaParole{
public static void main(String[] args) throws FileNotFoundException{
File f=new File(args[0]);
Scanner sc=new Scanner(f);
List<String> s=new LinkedList<String>();
while(sc.hasNextLine()){
String righe=sc.nextLine();
if(s.contains(righe)){
s.add(righe);
}
}
for(String h:s){
System.out.println(h);
}
}
}
Il problema è che da terminale non stampa niente.Dov'è che ho sbagliato?