0

I want to iterate through the HashMap and this is part of the code:

HashMap<Long, Integer> users = ((HashMap<Long, Integer>) getArguments().getSerializable("HashMap"));

Iterator it = users.entrySet().iterator();

04-25 19:13:31.070: E/AndroidRuntime(1446): java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Set java.util.HashMap.entrySet()' on a null object reference

I looked at the users variable and it does contain a table with keys and values.

chiwangc
  • 3,566
  • 16
  • 26
  • 32
Nathan Fowler
  • 561
  • 5
  • 19
  • 6
    Please update the question with a [minimal, complete example](http://stackoverflow.com/help/mcve) that reproduces the behavior you are seeing. – Radiodef Apr 26 '15 at 01:04
  • 3
    It's obvious `users` is `null` but we dont know why with the information given. – locoyou Apr 26 '15 at 01:11
  • `getArguments().getSerializable("HashMap")` is returning a `null`. You have to find out why that is so the second line does not case NPE exception. – fleed Apr 26 '15 at 01:27
  • I'm going to close this as a duplicate. If you can prove beyond a shadow of a doubt that `users` isn't null, then I'll be happy to reopen this. – Makoto Apr 26 '15 at 01:36

0 Answers0