Why my code is puting value withou key first and then rest? Any solution to that problem?
package pl.codegym.task.task10.task1019;
import java.io.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/*
Funkcjonalność to nie wszystko!
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
HashMap<String, Integer> mapa = new HashMap<String, Integer>();
String s;
int i;
while (true){
i = Integer.parseInt(reader.readLine());
s = reader.readLine();
mapa.put(s, i);
if (s.isEmpty()){
break;
}
}
for (Map.Entry<String, Integer> para:mapa.entrySet()){
System.out.println(para.getValue() + " " + para.getKey());
}
}
}