I have two classes as below. In class BBB, I want to pass the variable name (in strVarName variable) I want to access from class AAA. Is it possible to do so?
public class AAA{
String strName = "SomeName";
String strAddress = "SomeAddress";
String strPhone = "1231234567";
public static void main(String[] args) {
int intTest;
intTest = 10/2;
System.out.println (intTest)
}
}
public class BBB{
public static void main(String[] args) {
String strVarName;
strVarName = "strName";
AAA objAAA = new AAA();
System.out.println(objAAA.strVarName);//How to achive this line of code
}
}