
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Anvi Jain has Published 569 Articles

Anvi Jain
793 Views
To set the alignment of the label content along the X axis, use the setHorizontalAlignment() method. Let us first set a label component. We have set the label background color as well so that we can check the alignment of the label’s content properly −JLabel label = new JLabel("Team "); ... Read More

Anvi Jain
1K+ Views
You can use regular expression along with $not operator to ignore a specific character and display rest of them. Let us first create a collection with documents −> db.regexDemo.insertOne({"CustomerId":"Customer#1234", "CustomerName":"Chris"}); { "acknowledged" : true, "insertedId" : ObjectId("5cc7428f8f9e6ff3eb0ce436") } > db.regexDemo.insertOne({"CustomerId":"Customer5678", "CustomerName":"Robert"}); { "acknowledged" : true, "insertedId" ... Read More

Anvi Jain
590 Views
You can use $literal operator along with aggregate framework. Let us first create a collection with documents −> db.fieldWithStaticValue.insertOne({"Name":"Larry", "Age":24}); { "acknowledged" : true, "insertedId" : ObjectId("5cd6554c7924bb85b3f48948") } > db.fieldWithStaticValue.insertOne({"Name":"Chris", "Age":23}); { "acknowledged" : true, "insertedId" : ObjectId("5cd655567924bb85b3f48949") } > db.fieldWithStaticValue.insertOne({"Name":"David", "Age":26}); { "acknowledged" : ... Read More

Anvi Jain
457 Views
To get the node at a specified index in a JTree, use the getChildAt() method. Here, we are finding the node at index 3 i.e. 4th node −node.getChildAt(3)The following is an example to get the node at a specified index in a JTree −Examplepackage my; import javax.swing.JFrame; import javax.swing.JTree; import ... Read More

Anvi Jain
1K+ Views
You need to use changeUserPassword() to change a user’s password. Let us first create a user with some roles. Following is the query to create a user in MongoDB −> use admin switched to db admin > db.createUser( ... { ... user: "Chris", ... ... Read More

Anvi Jain
350 Views
To push elements to an existing array, use $addToSet operator along with update(). Let us first create a collection with documents −> db.pushElements.insertOne({"Comments":["Good", "Awesome", "Nice"]}); { "acknowledged" : true, "insertedId" : ObjectId("5cd682597924bb85b3f48953") }Following is the query to display all documents from a collection with the help of find() ... Read More

Anvi Jain
544 Views
Here we will see the Shuffle and random_shuffle in C++. Let us see the random_shuffle first. It is used to randomly rearrange the elements in range [left, right). This function randomly swaps the positions of each element with the position of some randomly chosen positions.We can provide some random generator ... Read More

Anvi Jain
175 Views
This is a C++ program to repeatedly search the same text.AlgorithmsBegin Take the original string and pattern to be searched as input. org_len = store the length of original string pat_len = store the length of pattern for i = 0 to (org_len - pat_len) ... Read More

Anvi Jain
276 Views
For this, use printjson. Let us first create a collection with documents −> db.cursorDemo.insertOne({"StudentFullName":"John Smith", "StudentAge":23}); { "acknowledged" : true, "insertedId" : ObjectId("5cc7f0d08f9e6ff3eb0ce442") } > db.cursorDemo.insertOne({"StudentFullName":"John Doe", "StudentAge":21}); { "acknowledged" : true, "insertedId" : ObjectId("5cc7f0df8f9e6ff3eb0ce443") } > db.cursorDemo.insertOne({"StudentFullName":"Carol Taylor", "StudentAge":20}); { "acknowledged" : true, ... Read More

Anvi Jain
351 Views
You can use $group operator with _id: null. Following is the syntax −db.yourCollectionName.aggregate([{$group: {_id:null, "anyFieldName": {$avg:"$yourFieldName"} } }]);Let us first create a collection with documents −> db.caculateTheAverageValueDemo.insertOne({"Population":100}); { "acknowledged" : true, "insertedId" : ObjectId("5cd68a197924bb85b3f4895f") } > db.caculateTheAverageValueDemo.insertOne({"Population":500}); { "acknowledged" : true, "insertedId" : ObjectId("5cd68a1c7924bb85b3f48960") } > ... Read More