title: JSP access methods of objects in a list
body: <p>I have 2 java classes. One is a java bean and the other is a collection of instances from this java bean class.</p>
  
  <pre><code>public class Quiz{ 
    private int id;
    private String title;
    //getters and setters 
  }
  
  public class Quizzes{
    List&lt;Quiz&gt; quizList = new ArrayList&lt;Quiz&gt;;
    public Quizzes{
      //constructor to add Quiz objects to quizList
      Quiz curQuiz = new Quiz();
      ...
    }
    public List&lt;Quiz&gt; getQuizList(){
      return this.quizList;
    }
  
  }
  </code></pre>
  
  <p>In my JSP I want to access for example the id (or title) of a Quiz. How can I do this? The only Idea I have is to iterate over the Objects in quizlist and call getId Method, and then add this Integer Values to a List. For example like this:</p>
  
  <pre><code>public List&lt;Integer&gt; getId(){
      List&lt;Integer&gt; idList = new ArrayList&lt;Integer&gt;();
      ListIterator&lt;Quiz&gt; ir = quizlist.listIterator();
      int id;
      while (ir.hasNext()){
          Quiz curQuiz = ir.next();
          id = curQuiz.getId();
          idList.add(id);
      }
      return idList;
  }
  </code></pre>
  
  <p>But isn't there a better solution?</p>