You need to sign in to do that
Don't have an account?
Mathew Andresen 5
Understanding scope
Hi,
If I decalre a variable in the first part of my class outside any of the methods, it should be available within all of my methods yes? But for some reason that's not working here, I don't understand what's wrong. There must be somethign I'm missing
Thanks,
If I decalre a variable in the first part of my class outside any of the methods, it should be available within all of my methods yes? But for some reason that's not working here, I don't understand what's wrong. There must be somethign I'm missing
Thanks,
public class ContactReclassTest { String confirstName; String conlastName; List<Contact> conList = New List<Contact>(); // this should be seen by within all methods yes? ContactReclassTest() { conFirstName = 'Mathew'; conlastName = 'Andresen'; } public static void createContacts() { List<Contact> conList = New List<Contact>(); // If I don't put this in it says the variable doesn't exist for(Integer i = 0; i < 5; i++) { Contact con = new Contact(FirstName = 'Mathew', LastName = ('Andresen'+ i) ); //can't find the other strings I declared either conList.add(con); } insert(conList); } }
All Answers