Anvi Jain

Anvi Jain

427 Articles Published

Articles by Anvi Jain

Page 34 of 43

How to use lastIndexOf () in Android textview?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 366 Views

This example demonstrate about How to use lastIndexOf () in Android textview.Step 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.             In the above code, we have taken name as Edit text, when user click on button it will take data and returns last index of “sai”.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; ...

Read More

How to use replace () in Android textview?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 2K+ Views

This example demonstrate about How to use replace () in Android textview.Step 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.             In the above code, we have taken name as Edit text, when user click on button it will take data and replace all a values withStep 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; ...

Read More

Get a count of total documents with MongoDB while using limit?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 791 Views

You can use $facet operator for this. To understand the concept, let us create a collection with document. The query to create a collection with document is as follows −> db.totalDocumentDemo.insertOne({"InstructorId":100, "InstructorName":"Larry", "InstructorFav ouriteSubject":["Java", "MongoDB", "Python"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c76e6701e9c5dd6f1f78274") } > db.totalDocumentDemo.insertOne({"InstructorId":200, "InstructorName":"Sam", "InstructorFav ouriteSubject":["SQL Server", "C#", "Javascript"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c76e69c1e9c5dd6f1f78275") }Display all documents from a collection with the help of find() method. The query is as follows −> db.totalDocumentDemo.find().pretty();Output{    "_id" : ObjectId("5c76e6701e9c5dd6f1f78274"),    "InstructorId" : 100,    "InstructorName" : "Larry",    "InstructorFavouriteSubject" : [     ...

Read More

Find largest document size in MongoDB?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 897 Views

To find the largest document size in MongoDB, you need to write a script in the shell.To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.largestDocumentDemo.insertOne({"StudentName":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8ed2e32f684a30fbdfd57d") } > db.largestDocumentDemo.insertOne({"StudentName":"Carol", "StudentAge":22, "StudentCountryName":"US", "TechnicalSubject":["C", "C++", "Java", "MySQL"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8ed3282f684a30fbdfd57e") } > db.largestDocumentDemo.insertOne({"StudentName":"Mike", "StudentAge":22}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8ed3382f684a30fbdfd57f") }Display all documents from a collection with the help of find() method. The query is as follows −> ...

Read More

C++ Program to Generate N Number of Passwords of Length M Each

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 329 Views

This is a C++ Program to Generate N Number of Passwords of Length M Each.AlgorithmBegin    Take the length of password as input.    function permutation() generate random passwords:    /* Arguments       A pointer array a.       Total Number of random numbers m.       Length of the password s.    */    // Body of the function:    if (m == s)       for i = 0 to s-1          Print *(a + i)    else       for i = m to s-1       ...

Read More

How to use startsWith () in Android textview?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 357 Views

This example demonstrate about How to use startsWith () in Android textview.Step 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 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    EditText name;    Button button;    TextView text;    @Override    protected void onCreate(Bundle savedInstanceState) {       ...

Read More

Get MongoDB documents with max attribute per group in a collection?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 416 Views

You can get documents with max attribute per group in a collection using $sort operator along with $group statement.To understand the concept further, let us create a collection with document. The query to create a collection with document is as follows −> db.maxAttributePerGroup.insertOne({"StudentFirstName":"John", "StudentLastName":"Smith    ", "StudentAge":29, "StudentId":10}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c76ee341e9c5dd6f1f78277") } > db.maxAttributePerGroup.insertOne({"StudentFirstName":"Carol", "StudentLastName":"Taylo    r", "StudentAge":19, "StudentId":10}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c76ee4e1e9c5dd6f1f78278") } > db.maxAttributePerGroup.insertOne({"StudentFirstName":"Adam", "StudentLastName":"Smit    h", "StudentAge":34, "StudentId":20}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c76ee631e9c5dd6f1f78279") } > db.maxAttributePerGroup.insertOne({"StudentFirstName":"Bob", "StudentLastName":"Taylor"    , "StudentAge":58, "StudentId":20}); { ...

Read More

Opposite of $addToSet to '$removeFromSet' in MongoDB?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 1K+ Views

To get the opposite of $addToSet to '$removeFromSet', use the $pull operator.Let us create a collection with a document. The query to create a collection with a document is as follows −> db.oppositeAddToSetDemo.insertOne({"StudentName":"John", "StudentHobby":["Cricket", "Cooking", "Drawing"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8eddcc2f684a30fbdfd588") } > db.oppositeAddToSetDemo.insertOne({"StudentName":"Carol", "StudentHobby":["Cricket", "Dance", "Hiking"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8eddfd2f684a30fbdfd589") } > db.oppositeAddToSetDemo.insertOne({"StudentName":"David", "StudentHobby":["Learning", "Photography"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8ede272f684a30fbdfd58a") }Display all documents from a collection with the help of find() method. The query is as follows −> db.oppositeAddToSetDemo.find().pretty();The following is the output −{    "_id" ...

Read More

How to list all users in the Mongo shell?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 13K+ Views

In order to list all users in the Mongo shell, use the getUsers() method or show command.Case 1 − Using getUsers()The syntax is as follows −db.getUsers();Case 2 − Using show commandThe syntax is as follows −show users;Let us implement both the syntaxes in order to list all users in the Mongo shell.Case 1 − The first query is as follows −> db.getUsers();The following is the output −[    {       "_id" : "test.John",       "user" : "John",       "db" : "test",       "roles" : [          {     ...

Read More

MongoDB SELECT COUNT GROUP BY?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 324 Views

You can achieve this with the help of an aggregate framework. To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.countGroupByDemo.insertOne({"StudentId":10, "StudentName":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7700871e9c5dd6f1f78296") } > db.countGroupByDemo.insertOne({"StudentId":10, "StudentName":"Carol"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c77008f1e9c5dd6f1f78297") } > db.countGroupByDemo.insertOne({"StudentId":20, "StudentName":"Sam"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7700971e9c5dd6f1f78298") } > db.countGroupByDemo.insertOne({"StudentId":30, "StudentName":"Mike"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7700a21e9c5dd6f1f78299") } > db.countGroupByDemo.insertOne({"StudentId":30, "StudentName":"David"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7700aa1e9c5dd6f1f7829a") } ...

Read More
Showing 331–340 of 427 articles
« Prev 1 32 33 34 35 36 43 Next »
Advertisements