I get this error whenever I run the below code:
Error - Only top-level class methods can be declared static
Code
public class ContactSearch
{
public static List<Contact> searchForContacts(String lastName, String mailCode)
{
return [SELECT Id, Name, LastName, MailingPostalCode
FROM Contact
WHERE LastName = :lastName AND MailingPostalCode = :mailCode];
}
}
Does anyone know why this is happening? I can't find the issue. I ran the accounts code the same way and it worked so I am confused with this error message.
(I tried to look for the answer in previous posts, but none applied to my case, therefore I am posing this new question.)