warum funktioniert while(reader.hasNext() ) nicht?
package de.codegym.task.task10.task1019;
import java.io.*;
import java.util.*;
/*
Funktionalität ist nicht genug!
*/
public class Solution {
static HashMap<String, Integer> map;
static Integer index;
static String string;
public Solution() {
this.map = new HashMap<String, Integer>();
}
public static void main(String[] args) throws IOException {
Solution solution = new Solution();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while(!map.isEmpty()){ // idee 3 = !reader.next().isEmpty() // idee 4 = reader.hasNext()
int index = Integer.parseInt(reader.readLine());
String string = reader.readLine();
solution.map.put(string, index);
// idee 1 = !(index.hasNext() ?
// idee 2 = reader.next().isEmpty() ?
}
for(Map.Entry<String, Integer> paar : map.entrySet()){
String key = paar.getKey();
int value = paar.getValue();
System.out.println("Id=" + key + " Name=" + value);
}
}
}