title: Finding size of a ArrayList where list name is passed as a String
body: <p>I have an ArrayList of a java object with name say, "mylist".
  I am getting the name of the list(mylist) from database which comes as a String. I need to find the size of this list in JAVA and need to iterate over it.</p>
  
  <p>Is there a way to do this?</p>
  
  <p>Edit:
  To be more clear here, I have a class "Candidate"</p>
  
  <pre><code>class Candidate {
  
      String firstName;
      String lastName;
      List&lt;Education&gt;educationRecords;
      .....
  }
  
  class Education {
  
      String school;
      String degree;
      .....
  }
  </code></pre>
  
  <p>I need to populate Candidate object from a JSONObject whose structure is very different from Candidate object(so can't use Gson or jackson).</p>
  
  <p>The simple fields like firstName, lastName, school and degree are stored in the database. </p>
  
  <p>I fetch a Listfields and iterate over them to set the Candidate object. For setting firstName, lastName, I am using SpEL.</p>
  
  <p>But, for fields like school and degree, it becomes complex as I would need to know the size of education records in JSONObject.</p>
  
  <p>So, what I thought was while iterating over all fields if school field is present in Education class(using reflection), I would need to check if educationRecords is a of List type in Candidate class and then by some logic X(taking educationRecords as variable name) iterate over it.</p>
  
  <p>It is the logic "X" I am missing.</p>