Chandu yadav has Published 1090 Articles

The toArray() method of Java AbstractCollection class

Chandu yadav

Chandu yadav

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

148 Views

The toArray() method of the AbstractCollection class is used to return the elements in this collection. The elements are returned in the form of an array.The syntax is as followspublic Object[] toArray()To work with AbstractCollection class in Java, import the following packageimport java.util.AbstractCollection;At first, declare AbstractCollection and add some elementsAbstractCollection ... Read More

Search a string with special characters in a MongoDB document?

Chandu yadav

Chandu yadav

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

2K+ Views

To search a string with special characters in MongoDB document, you can use \. Here, we have special character $ in our string.Let us first implement the following query to create a collection with documents>db.searchDocumentWithSpecialCharactersDemo.insertOne({"UserId":"Smith$John123", "UserFirstName":"John", "UserLastName":"Smith"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c987b98330fd0aa0d2fe4b1") } >db.searchDocumentWithSpecialCharactersDemo.insertOne({"UserId":"Taylor$Carol983", "UserFirstName":"Carol", "UserLastName":"Taylor"}); ... Read More

How to add a “created at” column in a table to set the timestamp in MySQL?

Chandu yadav

Chandu yadav

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

4K+ Views

You need to use ALTER command to add a created at column to an already created table in MySQL.Let us first create a table. The query to create a table is as follows. Here is your table without the “created at” columnmysql> create table formDemo - > ... Read More

IntStream allMatch() method in Java

Chandu yadav

Chandu yadav

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

584 Views

The allMatch() method of the IntStream class in Java returns whether all elements of this stream match the provided predicate.The syntax is as followsboolean allMatch(IntPredicate predicate)Here, the predicate parameter is a stateless predicate to apply to elements of this stream. The IntPredicate represents a predicate of one int-valued argument.The allMatch() ... Read More

How to get all the collections from all the MongoDB databases?

Chandu yadav

Chandu yadav

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

557 Views

To get all the collections from all the databases, let us first get all the databases using the following query> switchDatabaseAdmin = db.getSiblingDB("admin"); admin > allDatabaseName = switchDatabaseAdmin.runCommand({ "listDatabases": 1 }).databases;This will produce the following output[    {       "name" : "admin",       "sizeOnDisk" : 495616, ... Read More

Change a MySQL Column datatype from text to timestamp?

Chandu yadav

Chandu yadav

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

3K+ Views

To change a MySQL column datatype from text to timestamp, you need to use ALTER command.The syntax is as followsALTER TABLE yourTableName MODIFY COLUMN yourColumnName TIMESTAMP;To understand the above syntax, let us create a table.The query to create a table is as followsmysql> create table textTotimestampdemo    - > ( ... Read More

LongStream forEach() method in Java

Chandu yadav

Chandu yadav

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

190 Views

The forEach() method of the LongStream class in Java performs an action for each element of this stream.The syntax is as followsvoid forEach(LongConsumer action)Here, the parameter action is a non-interfering action to perform on the elements. LongConsumer represents an operation that accepts a single long-valued argument and returns no result.To ... Read More

Search for a text in MongoDBs Double Nested Array?

Chandu yadav

Chandu yadav

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

147 Views

Search for a text in MongoDBs Double Nested Array with the help of dot(.) notation. Let us first create a collection. Following is the query to create a collection with documents> db.doubleNestedArrayDemo.insertOne( ...    { ...       "StudentId" : "1000", ...       "StudentName" : "Larry", ... ... Read More

How to get default device sdk version in android?

Chandu yadav

Chandu yadav

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

222 Views

This example demonstrate about How to get default device sdk version in android.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 ... Read More

Can we exclude entries with “0” while using MySQL AVG function?

Chandu yadav

Chandu yadav

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

5K+ Views

To exclude entries with “0”, you need to use NULLIF() with function AVG().The syntax is as followsSELECT AVG(NULLIF(yourColumnName, 0)) AS anyAliasName FROM yourTableName;Let us first create a tablemysql> create table AverageDemo    - > (    - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    - > StudentName varchar(20), ... Read More

Advertisements