Timeline for System.NullPointerException when using .contains in a for loop
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 16, 2017 at 22:31 | comment | added | Adrian Larson♦ | That makes more sense. Avoid null collections wherever possible. | |
Jun 16, 2017 at 22:29 | vote | accept | Kamil Mieczakowski | ||
Jun 16, 2017 at 22:26 | comment | added | Kamil Mieczakowski | Sorry Adrian, it worked now. It must have been the API not being responsive for a split second. Thank you for your help! As an FYI I didn't put a null map in a list, it's just some values in some maps in the list are null while others aren't. | |
Jun 16, 2017 at 22:26 | comment | added | Adrian Larson♦ |
I don't know why you would put a null map in a list...you haven't shown us how you build that list so it's impossible to answer.
|
|
Jun 16, 2017 at 22:25 | comment | added | Kamil Mieczakowski | Could it be the fact that I am getting the relevant string from a list of maps? that's what it is: String investmentsRow = allRows[i].get('Names'); It works when I debug it... | |
Jun 16, 2017 at 22:23 | comment | added | Adrian Larson♦ | @KamilMieczakowski Then you are getting the error on a different line. Double check your stack trace. | |
Jun 16, 2017 at 22:22 | comment | added | Kamil Mieczakowski | yes, I also pasted it in the above comment for your evaluation | |
Jun 16, 2017 at 22:20 | comment | added | Adrian Larson♦ |
@KamilMieczakowski Did you replace if (namesRow.contains('Andrew')) entirely?
|
|
Jun 16, 2017 at 22:18 | history | edited | Adrian Larson♦ | CC BY-SA 3.0 |
added 591 characters in body
|
Jun 16, 2017 at 22:18 | comment | added | Kamil Mieczakowski |
I am still getting the same error when using your if class, for your reference, that's how it looks: if (namesRow != null && namesRow.contains('Andrew')){ system.debug('this name is in the list!'); }
|
|
Jun 16, 2017 at 22:16 | history | answered | Adrian Larson♦ | CC BY-SA 3.0 |