You need to sign in to do that
Don't have an account?
Sohail Barat 14
Non-void method might not return a value or might have statement after a return statement.
I am getting this error in my code:
Non-void method might not return a value or might have statement after a return statement.
My code is as under:
public class ContactSearch {
public static list<contact> searchForContacts(String Surname,String PCode)
{
list<Contact> ListIDandName = [select ID, name, phone from contact];
for(Contact search: ListIDandName)
{
if(search.name==surname && search.MailingPostalCode==PCode)
{
return ListIDandName;
}
}
}
}
Non-void method might not return a value or might have statement after a return statement.
My code is as under:
public class ContactSearch {
public static list<contact> searchForContacts(String Surname,String PCode)
{
list<Contact> ListIDandName = [select ID, name, phone from contact];
for(Contact search: ListIDandName)
{
if(search.name==surname && search.MailingPostalCode==PCode)
{
return ListIDandName;
}
}
}
}
All Answers