@@ -129,7 +129,7 @@ Now, translate the following into a MongoDB query.
129129 }
130130 ```
131131 </div >
132- </ TabItem >
132+
133133 <TabItem value = " python" label = " Python" >
134134 <div >
135135 ``` python
@@ -141,6 +141,26 @@ Now, translate the following into a MongoDB query.
141141 print (f " Book Title: { title} - Total Inventory: { inventory} " )
142142 ```
143143 </div >
144+ </TabItem >
145+ </TabItem ><TabItem value = " java" label = " Java" >
146+ <div >
147+ ``` java
148+ Bson filter = eq(" totalInventory" , 5 );
149+
150+ Bson projection = Projections . fields(
151+ Projections . include(" title" , " year" , " totalInventory" ));
152+
153+ List<Document > results = books. find(filter)
154+ .projection(projection)
155+ .into(new ArrayList<> ());
156+
157+ if (results. isEmpty()) {
158+ System . out. println(" No books were found for the given query." );
159+ } else {
160+ results. forEach(doc - > System . out. println(doc. toJson()));
161+ }
162+ ```
163+ </div >
144164 </TabItem >
145165 </Tabs >
146166
@@ -185,7 +205,7 @@ Now, translate the following into a MongoDB query.
185205 }
186206 ```
187207 </div >
188- </TabItem >
208+ </TabItem >
189209 <TabItem value = " python" label = " Python" >
190210 <div >
191211 ``` python
@@ -196,6 +216,26 @@ Now, translate the following into a MongoDB query.
196216 ```
197217 </div >
198218 </TabItem >
219+ <TabItem value = " java" label = " Java" >
220+ <div >
221+ ``` java
222+ Bson filter = gt(" pages" , 300 );
223+
224+ Bson projection = Projections . fields(
225+ Projections . include(" title" , " genres" , " pages" ));
226+
227+ List<Document > results = books. find(filter)
228+ .projection(projection)
229+ .into(new ArrayList<> ());
230+
231+ if (results. isEmpty()) {
232+ System . out. println(" No books were found for the given query." );
233+ } else {
234+ results. forEach(doc - > System . out. println(doc. toJson()));
235+ }
236+ ```
237+ </div >
238+ </TabItem >
199239 </Tabs >
200240</details >
201241
@@ -246,8 +286,8 @@ Now, translate the following into a MongoDB query.
246286 }
247287 ```
248288 </div >
249- </TabItem >
250- <TabItem value = " python" label = " Python" >
289+ </TabItem >
290+ <TabItem value = " python" label = " Python" >
251291 <div >
252292 ``` python
253293 books_with_genre_science_and_more_than_300_pages = books.find({" genres" : " Science" , " pages" : {" $gt" : 300 }})
@@ -257,5 +297,27 @@ Now, translate the following into a MongoDB query.
257297 ```
258298 </div >
259299 </TabItem >
300+ <TabItem value = " java" label = " Java" >
301+ <div >
302+ ``` java
303+ Bson filter = and(
304+ eq(" genres" , " Science" ),
305+ gt(" pages" , 300 ));
306+
307+ Bson projection = Projections . fields(
308+ Projections . include(" title" , " genres" , " pages" ));
309+
310+ List<Document > results = books. find(filter)
311+ .projection(projection)
312+ .into(new ArrayList<> ());
313+
314+ if (results. isEmpty()) {
315+ System . out. println(" No books were found for the given query." );
316+ } else {
317+ results. forEach(doc - > System . out. println(doc. toJson()));
318+ }
319+ ```
320+ </div >
321+ </TabItem >
260322 </Tabs >
261323</details >
0 commit comments