You need to sign in to do that
Don't have an account?
Not able to access global variable in inner class methods
HI All,
I have declared a global variable in outer class and trying to access that varibale in inner class method it is showing error.
Can any one help me plz it very urgernt.
global class GlobalTest{
global String value='Situ';
public class Myclass{
public void gtestMethod(){
System.debug(value);
}
}
}
Error is like Variable does not exist: value at line 6 column 24
Thanks
Situ
You can pass an instance of the parent class in to the constructor of the inner class like so...
You can define the variable ('value') as static then this variable can be used in inner class. Please us the following code:
global class GlobalTest{
global static String value='Situ';
public class Myclass{
public void gtestMethod(){
System.debug(value);
}
}
}
Thanks,