I have a problem, can anybody help? The line public void putWords () throws IOException { shows that there are some mistakes:
Multiple markers at this line
- Syntax error, insert ";" to complete
LocalVariableDeclarationStatement
- Syntax error, insert "[ ]" to complete Dimension
- Illegal modifier for parameter putWords; only final is permitted
- void[] is an invalid type
- Syntax error on token "putWords", AnnotationName expected after
this token
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Dictionary { // Локальный словарь private final HashMap<String, String> dictMap = new HashMap<>(); // Getter локального словаря public HashMap<String, String> getDictMap(){ return dictMap; } public void loadDictionary(File dictionary) throws FileNotFoundException { Scanner scanner = new Scanner(dictionary); String en = ""; String ukr = ""; String line; while(scanner.hasNext()){ line = scanner.nextLine(); en = line.substring(0,line.indexOf(" ")); ukr = line.substring(line.indexOf(" ") + 1); dictMap.put(en,ukr); } } public void showEnDictionary(){ for (Map.Entry<String, String> pair : dictMap.entrySet()) { System.out.println(pair.getKey() + " - " + pair.getValue()); } } public void searchEnWord(String word){ for (Map.Entry<String, String> pair : dictMap.entrySet()) { if(pair.getKey().equals(word)){ System.out.println(word + " - " + pair.getValue()); return; } } public void putWords () throws IOException { //mistakes are here String str; String path = "D://Dictionary.txt"; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new FileWriter(path, true)); try { while(true){ System.out.println("Enter the text : "); str = br.readLine(); if(str.equalsIgnoreCase("exit")) break; else pw.println(str); }} catch (Exception e) { } finally { pw.close(); } } System.out.println("\tСлово '"+ word +"' не знайдено в словнику"); } }