title: How to Call a Variable of a Class Using a String in Java
body: <p>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?</p>
  <pre><code>public class AAA{
  String strName = &quot;SomeName&quot;;
  String strAddress = &quot;SomeAddress&quot;;
  String strPhone = &quot;1231234567&quot;;
  
  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 = &quot;strName&quot;;
      AAA objAAA = new AAA();
      System.out.println(objAAA.strVarName);//How to achive this line of code 
  }
  }
  </code></pre>