title: Fill a list with objects from existing list object with particular value
body: <p>I have a list of objects which i want to iterate and for all objects that have particular value add them to a new list. Can i do that or i need a Map?
  example code:</p>
  
  <pre><code>List&lt;Object&gt; object = new ArrayList();
  Iterator iterator = object.iterator();
  while(iterator.hasNext()){
      Object listobject = (Object)iterator.next();
      if(object.getId() == 1){
         newlist.add(object);
  </code></pre>
  
  <p>The above code adds only the first object with this id. How can add all objects with this id in new list?
  thanx for your advice. </p>