@@ -24,8 +24,8 @@ documents that a read operation can return. If there are not enough documents
2424to reach the specified limit, it can return a smaller number.
2525If you use ``limit()`` with the ``skip()`` instance method, the skip applies
2626first and the limit only applies to the documents left over after
27- the skip. For more information on the ``skip()`` method, see our
28- :doc:`guide on Skipping Returned Documents </fundamentals/crud/read-operations/skip/>`.
27+ the skip. For more information on the ``skip()`` method, see our
28+ :doc:`guide on Skipping Returned Documents </fundamentals/crud/read-operations/skip/>`.
2929
3030The following examples demonstrate, respectively, how to insert data into
3131a collection, how to use ``limit()`` to restrict the number of returned documents,
@@ -64,9 +64,13 @@ longest books. It first matches all the documents with the query, then sorts on
6464books with shorter lengths. Lastly, it limits the return value to ``3`` documents:
6565
6666.. code-block:: java
67- :emphasize-lines: 6
67+ :emphasize-lines: 10
6868
69- import com.mongodb.client.model.Sorts;
69+ import com.mongodb.client.*;
70+ import org.bson.Document;
71+ import static com.mongodb.client.model.Sorts.descending;
72+
73+ // ...
7074
7175 // define a cursor that will return the first 3 sorted items
7276 MongoCursor<Document> cursor = collection.find()
@@ -109,14 +113,13 @@ Combining Skip and Limit
109113------------------------
110114
111115To see the next three longest books, append the ``skip()`` method to your
112- ``find()`` call. The integer argument passed to ``skip()`` will determine
113- how many documents the find operation returns:
116+ ``find()`` call as shown in the following code example:
114117
115118.. code-block:: java
116119 :emphasize-lines: 3, 4
117120
118121 MongoCursor<Document> cursor = collection.find()
119- .sort(ascending ("length"))
122+ .sort(descending ("length"))
120123 .limit(3)
121124 .skip(3)
122125 .iterator();
0 commit comments