I am trying to add space separated inputs to hashmap using for loop but I got some problems
int G = s.nextInt();
for (int i = 0; i < G; i++) {
System.out.println("List girls qualities");
int j=1;
String gir=s.next();
String[] numbers = gir.split(" ");
girlQualities=new HashMap<>();
for (int x=0;x<numbers.length;x++)
{
int z=Integer.parseInt(numbers[x]);
girlQualities.put(j,z);
j++;
}
}
When I used nextLine()
its showing NumberFormatException but even now its not working. Please help me
My target is to add numbers in this way
3
1 2 5 6
1 2 3 4 5
1 2 3 4