Smita Kapse has Published 558 Articles

Implementing MongoDB $exists and $ne?

Smita Kapse

Smita Kapse

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

281 Views

The $exists is used to check whethre a filed exists, whereas $ne is for not equal condition. Let us first create a collection with documents −> db.existsDemo.insertOne({"Name":"Chris", "Age":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7c3916d78f205348bc650") } > db.existsDemo.insertOne({"Name":"", "Age":null}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7c39a6d78f205348bc651") } > db.existsDemo.insertOne({"Name":null, "Age":24}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7c3a66d78f205348bc652") } > db.existsDemo.insertOne({"Age":23}); ... Read More

Why are NULL pointers defined differently in C and C++?

Smita Kapse

Smita Kapse

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

130 Views

In C++, a null pointer can be defined by as a null pointer constant is an integer constant expression with the value 0, like −int*p = 0;But in c, a null pointer can be defined by as a null pointer constant is an integer constant expression with the value 0 ... Read More

When should I write the keyword 'inline' for a function/method in C++?

Smita Kapse

Smita Kapse

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

134 Views

In C++, the inline keyword is used in different places. To create inline variables, or inline namespace, and as well as to create inline methods or functions.C++ inline function is powerful concept that is commonly used with classes. If a function is inline, the compiler places a copy of the ... Read More

Aggregate a $slice to get an element in exact position from a nested array in MongoDB?

Smita Kapse

Smita Kapse

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

142 Views

You can use aggregate framework for this. Let us first create a collection with documents −>db.exactPositionDemo.insertOne({"StudentName":"John", "StudentScores":[78, 98, 56, 45, 89]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd29a1c345990cee87fd883") }Following is the query to display all documents from a collection with the help of find() method −> db.exactPositionDemo.find().pretty();This will ... Read More

Java Program to set minor tick marks in a JSlider every 10 units

Smita Kapse

Smita Kapse

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

221 Views

Minor Tick marks is the number passed in representing the distance between each minor tick mark. For example, a slider with range from 0 to 70 and minor tick spacing 10, would give minor ticks next to the following values: 0, 10, 20, 30, 40, 50, 60, 70.To set minor ... Read More

Floating point comparison in C++

Smita Kapse

Smita Kapse

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

12K+ Views

Here we will see how to compare two floating point data using C++. The floating point comparison is not similar to the integer comparison.To compare two floating point values, we have to consider the precision in to the comparison. For example, if two numbers are 3.1428 and 3.1415, then they ... Read More

How to create android Notification intent to clear it self?

Smita Kapse

Smita Kapse

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

284 Views

This example demonstrate about How to create a local Notifications in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 ... Read More

Proper stack and heap usage in C++?

Smita Kapse

Smita Kapse

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

554 Views

The stack − All variables declared inside the function will take up memory from the stack. So, any local variable inside a function lives on the stack.The heap − This is unused memory of the program and can be used to allocate the memory dynamically when program runs. So If ... Read More

Combine update and query parts to form the upserted document in MongoDB?

Smita Kapse

Smita Kapse

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

116 Views

You need to use $set operator along with upsert:true. Let us first create a collection with documents −> db.updateWithUpsertDemo.insertOne({"StudentFirstName":"John", "StudentAge":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd2a61c345990cee87fd890") } > db.updateWithUpsertDemo.insertOne({"StudentFirstName":"Larry", "StudentAge":23}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd2a624345990cee87fd891") } > db.updateWithUpsertDemo.insertOne({"StudentFirstName":"David", "StudentAge":24}); {    "acknowledged" : ... Read More

How to set foreground color for different words in a JTextPane

Smita Kapse

Smita Kapse

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

917 Views

To set the foreground color for different words, use the SimpleAttributeSet and StyleConstants class. With that, use StyledDocument class as well for different words style. For different words, use insertString().At first, create a new JTextPane -At first, create a new JTextPane: JTextPane pane = new JTextPane();Now, use the classes to ... Read More

Advertisements