You need to sign in to do that
Don't have an account?

Private variables being accessed outside the class without using the GET SET method
Hi,
I was using the DEVELOPER CONSOLE, in my Public class i had two variables. inspite of declaring those variables as PRIVATE, i was accessing its values outside my class, but it shouldn't have been this way. if i was use the PRIVATE variables outside my Class, i should have use GET SET methods inside my class. for eg: the program goes like this
public class SFDC{
private string name;
private integer num;
private integer getnum(){
return num;}
}
SFDC sf = new SFDC();
sf.name='GAURAV';
sf.num=100;
system.debug(sf.getnum());
You can only access public variable outside the class, no matter if it has get set or not.