Anvi Jain has Published 569 Articles

Get maximum and minimum value in MongoDB?

Anvi Jain

Anvi Jain

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

2K+ Views

Use $max and $min operator along with aggregate framework to get the maximum and minimum value. Let us first create a collection with documents −> db.maxAndMinDemo.insertOne({"Value":98}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd698a357806ebf1256f129") } > db.maxAndMinDemo.insertOne({"Value":97}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd698af57806ebf1256f12a") } > db.maxAndMinDemo.insertOne({"Value":69}); ... Read More

How to write my own header file in C?

Anvi Jain

Anvi Jain

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

1K+ Views

Steps to write my own header file in C −Type a code and save it as “sub.h”.Write a main program “subtraction.c” in which −include new header file.Write “sub.h” instead of All the functions in sub.h header are now ready for use.Directly call the function sub().Both “subtraction.c” and “sub.h” should be ... Read More

How to set color to MatteBorder in Java?

Anvi Jain

Anvi Jain

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

192 Views

Set color to MatteBorder using the Color class −Border border = new MatteBorder(5, 10, 5, 5, Color.BLUE);Now, set it to a button component in Java −JButton button = new JButton("Matte Border"); button.setBorder(border);The following is an example to set color to MatteBorder in Java −Examplepackage my; import java.awt.BorderLayout; import java.awt.Color; import ... Read More

Removing an element from C++ std::vector<> by index?

Anvi Jain

Anvi Jain

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

422 Views

Remove an element from C++ std::vector by index can be done by following way −Example Live Demo#include #include using namespace std; int main() {    vector v; //declare vector    //insert elements into vector    v.push_back(-10);    v.push_back(7);    v.push_back(6);    // Deletes the first element (v[0])    v.erase(v.begin() );   ... Read More

What is a free function in C++?

Anvi Jain

Anvi Jain

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

374 Views

The C/C++ library function void free(void *ptr) deallocates the memory previously allocated by a call to calloc, malloc, or realloc. Following is the declaration for free() function.void free(void *ptr)This function takes a pointer ptr. This is the pointer to a memory block previously allocated with malloc, calloc or realloc to ... Read More

How to close the notification panel after notification button is clicked in Android?

Anvi Jain

Anvi Jain

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

2K+ Views

This example demonstrate about How to close the notification panel after notification button is clicked 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

Add MD5 hash value to MongoDB collection?

Anvi Jain

Anvi Jain

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

2K+ Views

To add MD5 hash value, use hex_md5(). Let us first create a collection with documents −>db.addMd5HashValueDemo.insertOne({"UserName":"Adam", "UserPassword":"Adam123456"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd6a4c66d78f205348bc619") } >db.addMd5HashValueDemo.insertOne({"UserName":"Chris", "UserPassword":"Chris_121#"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd6a4e46d78f205348bc61a") }Following is the query to display all documents from a collection with ... Read More

How to create notifications that do not go away when clicked in Android?

Anvi Jain

Anvi Jain

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

120 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

C++ Program to Implement Caesar Cypher

Anvi Jain

Anvi Jain

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

28K+ Views

It is a mono-alphabetic cipher wherein each letter of the plaintext is substituted by another letter to form the ciphertext. It is a simplest form of substitution cipher scheme.This cryptosystem is generally referred to as the Shift Cipher. The concept is to replace each alphabet by another alphabet which is ... Read More

How to change the maximum value of a JSlider in Java?

Anvi Jain

Anvi Jain

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

428 Views

To change the maximum value of a slider in Java, use the setMaximum() method wherein set the maximum value.Let’s say the following is our slider in Java −JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 55); slider.setMinorTickSpacing(10); slider.setMajorTickSpacing(25); slider.setPaintTicks(true); slider.setPaintLabels(true);Now, set the maximum value −slider.setMaximum(150);The following is an example to change ... Read More

Advertisements