I am iterating through an array of a List of Maps and want to run an if function whenever an item from the list meets a condition.
The problem I am currently facing is Salesforce producing the following error:
System.NullPointerException: Attempt to de-reference a null object
Here's the code with some more explanations:
for ( Integer i=1; i<allRows.size(); i++ ){
//this system.debug is to iterate over all lists, extract the values
//under the 'Names' header and display them in debug (IT WORKS)
system.debug(allRows[i].get('Names'));
String namesRow = allRows[i].get('Names');
//The below debug also produces the correct values
system.debug('namesRow is ' +namesRow);
//When the below function is active I am getting the NullPointerException Error
if (namesRow.contains('Andrew')){
system.debug('this name is in the database!');
}
}
}