Smita Kapse has Published 558 Articles

Java program to lay out components in a flow to be centered with FlowLayout?

Smita Kapse

Smita Kapse

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

155 Views

Use FlowLayout.CENTER to lay out components in a flow to be centered with FlowLayout. The following is an example to lay out components in a flow to be centered with FlowLayout −Examplepackage my; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextArea; import javax.swing.WindowConstants; public ... Read More

How to select where sum of fields is greater than a value in MongoDB?

Smita Kapse

Smita Kapse

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

265 Views

You can use $where operator for this. Let us first create a collection with documents −> db.sumOfFieldIsGreaterThanDemo.insertOne({"Price1":10, "Price2":50, "Price3":40}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cdd84b8bf3115999ed511e6") } > db.sumOfFieldIsGreaterThanDemo.insertOne({"Price1":11, "Price2":1, "Price3":120}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cdd84c6bf3115999ed511e7") } > db.sumOfFieldIsGreaterThanDemo.insertOne({"Price1":10, "Price2":9, "Price3":6}); {    "acknowledged" ... Read More

How to create a collection correctly in MongoDB to avoid “ReferenceError: Not defined” error?

Smita Kapse

Smita Kapse

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

1K+ Views

To create a collection correctly you need to use a MongoDB object in call i.e.db.createCollection("yourCollectionName");Let us implement the above syntax in order to create a collection and call it using a MongoDB object −> use sample; switched to db sample > db.createCollection("employeeInformation"); { "ok" : 1 }Display all the ... Read More

Why “using namespace std” is considered bad practice in C++

Smita Kapse

Smita Kapse

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

2K+ Views

C++ has a standard library that contains common functionality you use in building your applications like containers, algorithms, etc. If names used by these were out in the open, for example, if they defined a queue class globally, you'd never be able to use the same name again without conflicts. ... Read More

Check if a list is not empty in MongoDB?

Smita Kapse

Smita Kapse

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

339 Views

For this, use the $size operator. Let us first create a collection with documents −> db.checkIfListIsNotEmptyDemo.insertOne({"UserFriendGroup":["John", "David"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cdd99e8bf3115999ed511f7") } > db.checkIfListIsNotEmptyDemo.insertOne({"UserFriendGroup":["Carol"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cdd99e9bf3115999ed511f8") } > db.checkIfListIsNotEmptyDemo.insertOne({"UserFriendGroup":[]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cdd99ebbf3115999ed511f9") ... Read More

What is the difference between a destructor and a free function in C++?

Smita Kapse

Smita Kapse

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

451 Views

Here we will see what are the differences between destructor and the free() functions in C++. The destructor is used to perform some action, just before the object is destroyed. This action may not freeing up the memory, but can do some simple action such as displaying one message on ... Read More

Count the number of objects using Static member function in C++

Smita Kapse

Smita Kapse

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

5K+ Views

Here we will see how to count number of objects are created from a specific class using some static member functions. The static members are class properties, not the object properties. For a single class there will be only one instance for static members. No new members are created for ... Read More

How to get the number of rows and columns of a JTable in Java Swing

Smita Kapse

Smita Kapse

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

1K+ Views

To count the number of rows of a table, use the getRowCount() method −table.getRowCount()To count the number of columns of a table, use the getColumnCount() method −table.getColumnCount()The following is an example to get the number of rows and columns of a JTable −Examplepackage my; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JScrollPane; ... Read More

MongoDB query to find a value from JSON like data?

Smita Kapse

Smita Kapse

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

4K+ Views

To fund a value from JSON data, use the find() along with dot(.) notation. Let us first create a collection with documents −> db.findValueFromJsonDemo.insertOne(    {       "UserDetails": [{          "_id": new ObjectId(),          "UserName": "Carol",          "UserMessage": "Hi" ... Read More

What is the C++ equivalent of sprintf?

Smita Kapse

Smita Kapse

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

2K+ Views

The sprint() function is present inside the C and C++ also. This function is used to store something inside a string. The syntax is like the printf() function, the only difference is, we have to specify the string into it.In C++ also, we can do the same by using ostringstream. ... Read More

Advertisements