You need to sign in to do that
Don't have an account?
Pratiksha Shevade
Looping over a map throes Null Pointer Exception
Why am I getting a Null Pointer Exception during iterating a map in a FOR loop, even if there are corresponding values in the map?
system.debug('**stdmap**' + stdIdToxyzMap.get(std.id)); //Prints the values correctly. No Null pointer exception for(xyz__c x : stdIdToxyzMap.get(std.Id)){ //Throws Null Pointer Exception at this line system.debug('x:'+x.id); }
You can take reference from this below code.
In case you find any other issue please mention.
If you find your Solution then mark this as the best answer.
Thanks and Regards
Suraj Tripathi.
All Answers
You can take reference from this below code.
In case you find any other issue please mention.
If you find your Solution then mark this as the best answer.
Thanks and Regards
Suraj Tripathi.
I was running this in another for loop so for one of the keys, the values were coming as NULL and hence it was throwing the exception. Adding the null check before the loop solved the issue.
If you find your Solution then mark this as the best answer.