+ 1

Can you print the first argument by 'getting' the second?

I've written a small programme to see if I understood HashMaps, by using Scanner to let the user input their name and their age. When I use System.out.println("Hello " + info.get(age)); It displays "Hello null" So is there a way to make it work?

1st Feb 2017, 12:41 PM
Vincent
2 Respuestas
0
Nevermind, I just have to turn around the put arguments. I had info.put(name, age); Turning those around did it
1st Feb 2017, 12:43 PM
Vincent
0
getInt??
1st Feb 2017, 6:22 PM
Somnath Ghosh
Somnath Ghosh - avatar