title: How to loop over a Class attributes in Java - from a given list (NOT reflection getDeclaredFields())?
body: <p>How can I iterate over the attributes of an object, with the attribute names provided in a list/array - <strong>NOT all attributes</strong>, like using reflection &amp; <code>getDeclaredFields()</code>.</p>
  
  <pre><code>public class MyClass
  {
      public type1 att1;
      public type2 att2;
      public type3 att3;
  
      public MyClass(
          att1="helo";
          att2="bye";
          att3="morning";
      );
  
      ...
      public void function()
      {
          String myStrings[];
          myStrings = new String[] { "att2", "att3" };
  
          MyClass myobject = new MyClass();
          for(var in myStrings)
          {
             System.out.println(var);
             System.out.println(myobject.var);
             System.out.println();
          }
      }
  }
  </code></pre>