title: How to get first n rows in-memory from realm
body: <p>I want to get only first 10 or possibly n rows in-memory as java list using <strong>copyFromRealm</strong> method. Consider like this:</p>
  
  <pre><code>RealmResults&lt;RecentViewItem&gt; results = realm.where(RecentViewItem.class).findAllSorted("updatedAt", Sort.DESCENDING);
  // This will load all rows in-memory list
  List&lt;RecentViewItem&gt; list = realm.copyFromRealm(results);
  
  // But I want only first n rows without running any loop.
  </code></pre>
  
  <p><strong>UPDATE:</strong>
  Since RealmResult extends AbstractList -</p>
  
  <pre><code>RealmResults&lt;RecentViewItem&gt; results =
                  realm.where(RecentViewItem.class)
                          .findAllSorted("updatedAt", Sort.DESCENDING);
  List&lt;RecentViewItem&gt; temp = results.subList(0, maxNoRecentViewItem);   // Still list of RealmProxyObject
  List&lt;RecentViewItem&gt; list = realm.copyFromRealm(temp);   // List of RecentViewItem Object
  </code></pre>