+ Start a Discussion
Gaurav RajGaurav Raj 

Private variables being accessed outside the class without using the GET SET method


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();

Bhawani SharmaBhawani Sharma
You can only access public variable outside the class, no matter if it has get set or not.