Nishtha Thakur has Published 564 Articles

Why do we check for a NULL pointer before deleting in C/C++?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

386 Views

It is basically pointless to check for a NULL pointer before deleting. Deleting a pointer will do nothing if the pointer set to NULL. It might be the reason to check for the NULL pointer that deleting a pointer which is already set to NULL may indicate bugs in the ... Read More

MongoDB query to get record beginning with specific element from an array?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

149 Views

You can use dot(.) notation along with array index to get record beginning with specific element. Let us first create a collection with documents −>db.arrayStartsWithElementDemo.insertOne({"PlayerName":"Chris", "PlayerScore":[780, 9000, 456, 789, 987]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd29fed345990cee87fd889") } >db.arrayStartsWithElementDemo.insertOne({"PlayerName":"Robert", "PlayerScore":[890, 670, 890, 54646, 42424]}); {    "acknowledged" : ... Read More

How can I drop a collection in MongoDB with two dashes in the name?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

336 Views

Let us first see the syntax to drop a collection −db.getCollection("yourCollectionNameWithTwoDashes").drop();For demo, we will create a collection name with two dashes as shown below −> db.createCollection("company--EmployeeInformation"); { "ok" : 1 }Create the above collection “company--EmployeeInformation “ with documents. Following is the query:>db.getCollection("company--EmployeeInformation").insertOne({"CompanyName":"Amazon", "EmployeeName":"Chris"}); {    "acknowledged" : true,    "insertedId" ... Read More

Java Program to set a spinner of dates in Java

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

157 Views

To set a spinner of dates, at first create a date object −Date today = new Date();Now, use SpinnerDateModel −JSpinner spinner2 = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH));We will now consider a DateEditor, which is an editor for a JSpinner whose model is a SpinnerDateModel. Set the format for month ... Read More

How to include libraries in Visual Studio 2012?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

1K+ Views

To add libraries in Visual Studio 2012, there are two different methods. The first one is manual method. The second one is adding libraries from code.Let us see the manual method first.To add some library, we have to follow these five steps −Add the #include statements necessary files with proper ... Read More

Selecting database inside the JS in MongoDB?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

89 Views

You can use getSiblingDB() from MongoDB for this using var keyword from JS −anyVariableName= db.getSiblingDB(‘yourDatabaseName’);Let us implement the above syntax in order to select database −> selectedDatabase = db.getSiblingDB('sample');This will produce the following output −SampleNow, insert some documents. Let’s say the collection is ‘selectDatabaseDemo’ −> db.selectDatabaseDemo.insertOne({"ClientName":"John Smith", "ClientAge":23}); {   ... Read More

How to create a Default Cell Editor that uses a JCheckBox in Java?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

197 Views

Create a check box first and set valueJCheckBox checkBox = new JCheckBox("In-Stock");Set the JCheckBox for the editor so that the editor uses the check box −TreeCellEditor editor = new DefaultCellEditor(comboBox); tree.setEditable(true); tree.setCellEditor(editor);The following is an example to create a Default Cell Editor that uses a JCheckBox −Examplepackage my; import javax.swing.DefaultCellEditor; ... Read More

How do I catch a Ctrl+C event in C++?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

10K+ Views

The CTRL + C is used to send an interrupt to the current executing task. In this program, we will see how to catch the CTRL + C event using C++.The CTRL + C is one signal in C or C++. So we can catch by signal catching technique. For ... Read More

How to display vertical grid lines in a table with Java?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

294 Views

To display vertical grid lines in a table, use the setShowVerticalLines() method. Let us first create a table −String[][] rec = {    { "1", "Steve", "AUS" },    { "2", "Virat", "IND" },    { "3", "Kane", "NZ" },    { "4", "David", "AUS" },    { "5", "Ben", ... Read More

C++ Program to Implement Sparse Array

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

2K+ Views

A sparse matrix is a matrix in which majority of the elements are 0. An example for this is given as follows.The matrix given below contains 5 zeroes. Since the number of zeroes is more than half the elements of the matrix, it is a sparse matrix.0 0 9 5 ... Read More

Advertisements