Skip to content

Commit 46f0fa6

Browse files
author
Chris Cho
authored
Merge pull request #153 from ccho-mongodb/DOCS-13638-java-iterate-update
DOCS-13638: Update Java code example for result iteration
2 parents 53887eb + 33fe0bc commit 46f0fa6

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

source/includes/iterate_all.rst

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,23 @@
6767
- id: java-sync
6868
content: |
6969
70-
You can implement a ``com.mongodb.Block`` to print the results
71-
of the iteration
70+
You can implement a ``java.util.function.Consumer`` to print the
71+
results of the iteration
7272
7373
.. code-block:: java
7474
75-
Block<Document> printBlock = new Block<Document>() {
76-
@Override
77-
public void apply(final Document document) {
78-
System.out.println(document.toJson());
75+
Consumer<Document> printConsumer = new Consumer<>() {
76+
public void accept(final Document doc) {
77+
System.out.println(doc.toJson());
7978
}
8079
};
8180
8281
Then iterate the cursor for documents, passing the
83-
``printBlock`` as a parameter.
82+
``printConsumer`` as a parameter.
8483
8584
.. code-block:: java
8685
87-
findIterable.forEach(printBlock);
86+
findIterable.forEach(printConsumer);
8887
8988
- id: nodejs
9089
content: |

0 commit comments

Comments
 (0)