- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Nishtha Thakur has Published 564 Articles
Nishtha Thakur
361 Views
Set the selection mode to SINGLE_TREE_SELECTION, if you want only a single tree node to be selected −tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);The following is an example to allow only a single tree node to be selected in a JTree −Examplepackage my; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeSelectionModel; public class SwingDemo { ... Read More
Nishtha Thakur
656 Views
Use find() with dot notation to perform recursive search. Let us first create a collection with documents −> db.findOperationDemo.insertOne({"ClientDetails":[{"ClientId":101, "ClientName":"Chris"}, {"ClientId":102, "ClientName":"Robert"}]}); { "acknowledged" : true, "insertedId" : ObjectId("5cd9a118b50a6c6dd317ad99") } > db.findOperationDemo.insertOne({"ClientDetails":[{"ClientId":110, "ClientName":"David"}, {"ClientId":112, "ClientName":"Mike"}]}); { "acknowledged" : true, "insertedId" : ObjectId("5cd9a12fb50a6c6dd317ad9a") }Following is the query ... Read More
Nishtha Thakur
198 Views
Use DISTINCT for distinct elements and then length to get the size of array −db.yourCollectionName.distinct('yourFieldName').length;Let us first create a collection with documents −> db.countOrSizeDemo.insertOne({"StudentFirstName":"John"}); { "acknowledged" : true, "insertedId" : ObjectId("5cd304f5b64f4b851c3a13dc") } > db.countOrSizeDemo.insertOne({"StudentFirstName":"David"}); { "acknowledged" : true, "insertedId" : ObjectId("5cd304fab64f4b851c3a13dd") } > db.countOrSizeDemo.insertOne({"StudentFirstName":"David"}); { ... Read More
Nishtha Thakur
439 Views
Here we will see the Hygienic Macros in C. We know the usage of macros in C. But sometimes, it does not return the desired results because of accidental capture of identifiers.If we see the following code, we can see that it is not working properly.Example#include #define INCREMENT(i) do { ... Read More
Nishtha Thakur
80 Views
Yes, you can use capped parameter along with max size. Following is the syntax −db.createCollection("yourCollectionName", {capped:true, size:yourSizeInBytes, max:howManyRecordsYouWant})Let us first create a collection with capped:true −> db.createCollection("limitTheNumberOfRecordsDemo", {capped:true, size:200024, max:3}) { "ok" : 1 }We will now create a collection with documents −> db.limitTheNumberOfRecordsDemo.insertOne({"ClientName":"James Brown"}); { "acknowledged" : true, ... Read More
Nishtha Thakur
546 Views
Here we will see how to print numbers in a correct sequence using different threads. Here we will create n number of threads, then synchronize them. The idea is, the first thread will print 1, then second thread will print 2 and so on. When one thread is trying to ... Read More
Nishtha Thakur
243 Views
The strol() function is used to convert the string to long integers. It sets the pointer to point to the first character after the last one. The syntax is like below. This function is present into the cstdlib library.long int strtol(const char* str, char ** end, int base)This function takes ... Read More
Nishtha Thakur
744 Views
Use unique and set it to TRUE. Let us implement the same by creating index and setting two columns to unique −>db.keepTwoColumnsUniqueDemo.createIndex({"StudentFirstName":1, "StudentLastName":1}, {unique:true}); { "createdCollectionAutomatically" : true, "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1 }Now you can insert documents in the above collection ... Read More
Nishtha Thakur
50 Views
You can use $where operator for this. Let us first create a collection with documents −>db.veryStrictDocumentDemo.insertOne({"StudentFirstName":"John", "StudentLastName":"Doe", "StudentAge":23}); { "acknowledged" : true, "insertedId" : ObjectId("5cda4bcdb50a6c6dd317adb8") } > db.veryStrictDocumentDemo.insertOne({"StudentFirstName":"Larry"}); { "acknowledged" : true, "insertedId" : ObjectId("5cda4bdbb50a6c6dd317adb9") } >db.veryStrictDocumentDemo.insertOne({"StudentFirstName":"David", "StudentLastName":"Miller"}); { "acknowledged" : true, "insertedId" : ... Read More
Nishtha Thakur
867 Views
Here we will see one interesting problem. In this problem, we will see how to print Christmas tree randomly. So the tree will be flickering like Christmas tree lights.To print a Christmas tree, we will print pyramids of various sizes just one beneath another. For the decorative leaves a random ... Read More