Anvi Jain has Published 629 Articles

How to increment inside the update() function in MongoDB?

Anvi Jain

Anvi Jain

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

230 Views

You can use $inc operator to increment. Let us first create a collection with documents −> db.addInUpdateFunctionDemo.insertOne({"PlayerName":"Chris", "PlayerScore":78}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd2b3f4345990cee87fd893") } > db.addInUpdateFunctionDemo.insertOne({"PlayerName":"Robert", "PlayerScore":88}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd2b3fc345990cee87fd894") } > db.addInUpdateFunctionDemo.insertOne({"PlayerName":"David", "PlayerScore":99}); {    "acknowledged" : true,   ... Read More

How to set JCheckBoxMenuItem for a MenuItem in Java?

Anvi Jain

Anvi Jain

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

93 Views

Let’s say we have a menu and within that we need to set the JCheckBoxMenuItem. Here’s the Menu −JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic(KeyEvent.VK_E); menuBar.add(editMenu);Now, set the JCheckBoxMenuItem and add it to the editMenu created above −JCheckBoxMenuItem checkMenuItem = new JCheckBoxMenuItem("SelectAll"); checkMenuItem.setMnemonic(KeyEvent.VK_B); editMenu.add(checkMenuItem);The following is an example to set JCheckBoxMenuItem ... Read More

How to initialize const member variable in a C++ class?

Anvi Jain

Anvi Jain

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

14K+ Views

Here we will see how to initialize the const type member variable using constructor?To initialize the const value using constructor, we have to use the initialize list. This initializer list is used to initialize the data member of a class. The list of members, that will be initialized, will be ... Read More

C++ Program to Find Closest Pair of Points in an Array

Anvi Jain

Anvi Jain

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

678 Views

This is the program to find closest pair of points in an array.AlgorithmsFor Distance between Closest pointBegin    Declare function Closest_dist_Spoint(poi stp[], int s, double dist, poi &pnt1, poi &pnt2) to the double datatype.    Declare Minimum to the double datatype.       Initialize Minimum = dist.    for ... Read More

Java Program to set major tick marks in a JSlider every 25 units

Anvi Jain

Anvi Jain

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

250 Views

Major Tick marks is the number passed in representing the distance between each major tick mark. For example, a slider with range from 0 to 75 and major tick spacing 25, would give major ticks next to the following values: 0, 25, 50, 75.To set major tick marks, use the setMajorTickSpacing() ... Read More

Find objects created in last week in MongoDB?

Anvi Jain

Anvi Jain

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

349 Views

You can use Date() along with $gte operator to find objects created last week. Here the curdate is as follows in my system −> new Date(); ISODate("2019-05-14T08:32:42.773Z")Let us first create a collection with documents −> db.findObectInLastWeekDemo.insertOne({"ShippingDate":new ISODate("2019-05-01")}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cda7dc4bf3115999ed511e0") } > db.findObectInLastWeekDemo.insertOne({"ShippingDate":new ISODate("2019-05-02")}); ... Read More

Java Program to append a row to a JTable in Java Swing

Anvi Jain

Anvi Jain

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

608 Views

To append a row, you can use the addRow() method. Ley us first create a table wherein we need to append a row −DefaultTableModel tableModel = new DefaultTableModel(); JTable table = new JTable(tableModel);Add some columns to the table −tableModel.addColumn("Language/ Technology"); tableModel.addColumn("Difficulty Level");Add some rows −tableModel.insertRow(0, new Object[] { "CSS", "Easy" ... Read More

C++ Program to Create the Prufer Code for a Tree

Anvi Jain

Anvi Jain

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

675 Views

Prufer code uniquely identifies a tree which is given by user as a graph representation with labels from 1 to p. This tree consist p(value is given by user) labels of node. It has sequence of p – 2 values.AlgorithmBegin    Declare i, j, ver, edg, minimum, p to the ... Read More

How to get android notifications when the app was closed?

Anvi Jain

Anvi Jain

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

455 Views

This example demonstrate about How to get android notifications when the app was closedStep 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.     ... Read More

MongoDB query to replace value in an array?

Anvi Jain

Anvi Jain

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

1K+ Views

Use $set to replace value in an array. Let us first create a collection with documents −> db.replaceValueInArrayDemo.insertOne({"StudentScores":[45, 56, 78]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7f0421a844af18acdffb7") } > db.replaceValueInArrayDemo.insertOne({"StudentScores":[33, 90, 67]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7f0521a844af18acdffb8") }Following is the query to display all ... Read More

Advertisements