title: Better way of getting a list of ids
body: <p>This is the sample object i have</p>
  
  <pre><code>public class Dummy {
      private long id;
      private String name;
      /**
       * @return the id.
       */
      public long getId() {
          return id;
      }
      /**
       * @param id the id to set.
       */
      public void setId(long id) {
          this.id = id;
      }
      /**
       * @return the name.
       */
      public String getName() {
          return name;
      }
      /**
       * @param name the name to set.
       */
      public void setName(String name) {
          this.name = name;
      }
  
  }
  </code></pre>
  
  <p>My problem is this I have a list of these objects and I need to fetch the list of ids present in that object inside the list. I could easily do this by</p>
  
  <pre><code>List&lt;Long&gt; ids = Lists.newArrayList();
  for(Dummy dummy: dummyList){
   ids.add(dummy.getId()); 
  }
  </code></pre>
  
  <p>I am wondering if it can be done by using alternative approach(instead of using a for loop may be?) than what i have come up with may be using <code>Iterables</code> or <code>Collections</code> filtering?</p>
  
  <p>EDIT: I am interested in knowing how it can be done differently than i have come up with.</p>