Nishtha Thakur has Published 564 Articles

C++ Program to Implement LexicoGraphical_Compare in STL

Nishtha Thakur

Nishtha Thakur

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

64 Views

The C++ function std::algorithm::lexicographical_compare() tests whether one range is lexicographically less than another or not. A lexicographical comparison is the kind of comparison generally used to sort words alphabetically in dictionaries.Declarationtemplate bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);AlgorithmBegin    result = lexicographical_compare(v1.begin(), v1.end(), v2.begin(), v2.end())    if (result ... Read More

How to use JOptionPane with Array Elements in Java?

Nishtha Thakur

Nishtha Thakur

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

882 Views

Let us first create and array and add elements −String[] sports = { "Football", "Cricket", "Squash", "Baseball", "Fencing", "Volleyball", "Basketball" };Now, set the above array elements to the JOptionPane −String res = (String) JOptionPane.showInputDialog(null, "Which sports you play the most?", "Sports",    JOptionPane.PLAIN_MESSAGE, null, sports, sports[0]);Above, we have also set ... Read More

Insert data into inner array in MongoDB?

Nishtha Thakur

Nishtha Thakur

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

207 Views

You can use $addToSet operator for this. Let us first create a collection with documents −> db.insertDataIntoArrayDemo.insertOne(    {       "UserDetails":[          {             "UserId" :"user121",             "userGroupMessage":[]          },     ... Read More

How to check if input is numeric in C++?

Nishtha Thakur

Nishtha Thakur

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

5K+ Views

Here we will see how to check whether a given input is numeric string or a normal string. The numeric string will hold all characters that are in range 0 – 9. The solution is very simple, we will simply go through each characters one by one, and check whether ... Read More

How to read file content into istringstream in C++?

Nishtha Thakur

Nishtha Thakur

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

1K+ Views

Here is a C++ program to read file content into isstringstream in C++.Example#include #include #include using namespace std; int main() {    ifstream is("a.txt", ios::binary );    // get length of file:    is.seekg (0, std::ios::end);    long length = is.tellg();    is.seekg (0, std::ios::beg);    // allocate ... Read More

How to open last activity when tapping on Android notification?

Nishtha Thakur

Nishtha Thakur

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

599 Views

This example demonstrate about How to open last activity when tapping on Android notificationStep 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

How can I set an EtchedBorder from BorderFactory class to a component in Java?

Nishtha Thakur

Nishtha Thakur

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

154 Views

Set an EtchedBorder from BorderFactory class −EtchedBorder etchedBorder = (EtchedBorder)BorderFactory.createEtchedBorder();Now, set it for a component −JButton button = new JButton("Etched Border"); button.setBorder(etchedBorder);The following is an example to set an EtchedBorder from BorderFactory class to a component −Examplepackage my; import java.awt.BorderLayout; import java.awt.Container; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.border.Border; ... Read More

The best way to check if a file exists using standard C/C++

Nishtha Thakur

Nishtha Thakur

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

15K+ Views

The only way to check if a file exist is to try to open the file for reading or writing.Here is an example −In CExample#include int main() {    /* try to open file to read */    FILE *file;    if (file = fopen("a.txt", "r")) {       ... Read More

Getting a list of values by using MongoDB $group?

Nishtha Thakur

Nishtha Thakur

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

1K+ Views

To get a list of values, use $group aggregation along with $push operator. Let us first create a collection with documents −> db.groupByDemo.insertOne({"UserName":"John", "Subject":"MongoDB"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd69f0457806ebf1256f136") } > db.groupByDemo.insertOne({"UserName":"Larry", "Subject":"MySQL"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd69f0657806ebf1256f137") } > db.groupByDemo.insertOne({"UserName":"John", "Subject":"Java"}); ... Read More

How to start an activity when user clicks a notification in Android?

Nishtha Thakur

Nishtha Thakur

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

342 Views

This example demonstrate about How to start an activity when user clicks a notification 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. ... Read More

Advertisements