I want to check if the list "wordlist" has some elements from the list "list". If it has , these elements should be printed. Just have some difficulties with syntax to compare 2 lists in java. Here is my code:
File files = new File("E:/test/dictionary.txt");
String[] words = file.split(" ");
List<String> wordlist = Arrays.asList(words);
try {
    Scanner scanner = new Scanner(files);
    List<String> list = new ArrayList<>();
    while (scanner.hasNextLine()) {
        list.add(scanner.nextLine());
    }
    scanner.close();
    for (String word : wordlist) {
        System.out.println(word);
    }
    for (String oleg : list) {
        System.out.println(oleg);
    }
} catch (FileNotFoundException e) {
    e.printStackTrace();
}
 
     
     
    