How can we access Inner class methods or variables in salesforce from the anonymous window.Please refer the below example code:
public class OuterClass {
public String CompanyName;
public String CompanyAddress;
public void PrintCompany(String CompanyName, String CompanyAddress){
this.CompanyName = CompanyName;
this.CompanyAddress = CompanyAddress;
System.debug('Company name is : ' + CompanyName + '\n' + 'Company is located in : ' + CompanyAddress);
}
public class InnerClass{
public String ModelName;
public Integer Quantity;
public Integer Price;
public void Model(){
System.debug('InnnerClass');
}
}
}
Anonymous window code:
OuterClass Comp = new OuterClass();
Comp.PrintCompany('Royal Enfield','Jodhpur');
So from the code I am not sure on how I can access the variables or methods in the anonymous window of the 'InnerClass' class? Also, I have given the access modifier to the inner class as public. As we cannot access private inner class outside the outer class and can be accessed inside the outer class only.
Another Question: -can we have public variables in inner class when it is defined private? As the variables cant be more restrictive than the class is my assumption correct?