Chandu yadav

Chandu yadav

810 Articles Published

Articles by Chandu yadav

Page 64 of 81

DoubleStream anyMatch() method in Java

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 142 Views

The anyMatch() method of the DoubleStream class returns whether any elements of this stream match the provided predicate.The syntax is as followsboolean anyMatch(DoublePredicate predicate)Here, the parameter predicate is a stateless predicate to apply to elements of this stream. The DoublePredicate here is a predicate of one double-valued argument.To use the DoubleStream class in Java, import the following packageimport java.util.stream.DoubleStream;Create a DoubleStream and add some elements to the streamDoubleStream doubleStream = DoubleStream.of(67.9, 89.9, 10.5, 95.8, 49.6);Now, check if any of the elements match the predicateboolean res = doubleStream.anyMatch(a -> a > 50);The following is an example to implement DoubleStream anyMatch() method ...

Read More

Get the array of _id in MongoDB?

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 813 Views

The _id in MongoDB is a field, which is mandatory. In MongoDB, each document stored in a collection requires a unique _id field that acts as a primary key. Following is the syntax to get the array of all the ids i.e. _id in MongoDBdb.yourCollectionName.find({ _id : { $in : [yourValue1, yourValue2, yourValue3, .......N] } } );Let us first implement the following query to create a collection with documents> db.selectInWhereIdDemo.insertOne({"_id":23}); { "acknowledged" : true, "insertedId" : 23 } > db.selectInWhereIdDemo.insertOne({"_id":28}); { "acknowledged" : true, "insertedId" : 28 } > db.selectInWhereIdDemo.insertOne({"_id":45}); { "acknowledged" : true, "insertedId" : 45 } > db.selectInWhereIdDemo.insertOne({"_id":75}); ...

Read More

DoubleStream forEachOrdered() method in Java

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 157 Views

The forEachOrdered() method of the DoubleStream class in Java performs an action for each element of this stream. This assures that each element is processed in encounter order for streams that have a defined encounter order.The syntax is as followsvoid forEachOrdered(DoubleConsumer action)Here, DoubleConsumer represents an operation that accepts a single double-valued argument and returns no result. The parameter action is a non-interfering action to perform on the elements.To use the DoubleStream class in Java, import the following packageimport java.util.stream.DoubleStream;The following is an example to implement DoubleStream forEachOrdered() method in Java:Example Live Demoimport java.util.stream.DoubleStream; public class Demo {    public static void ...

Read More

Generation of triangular wave using DAC interface

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 7K+ Views

We write an 8085 assembly language program for the generation of triangular waveform using the Digital to Analog Converter (DAC) interface. The display of the waveform is seen on the CRO.Let us consider a problem solution in this domain. The problem states that: To get unipolar output, J1 is shorted to J2 on the interface. To display the waveform on a CRO, connect pin 1 of connector P1 to CRO signal pin, and pin 2 of connector P1 to CRO ground pin.Program; FILE NAME DAC_TO_TRIANG.ASM ORG C100H X DW 00FFH ; the fall of rise and time I proportional directly to ...

Read More

Check how many rows are in a MySQL database table?

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 1K+ Views

To know how many rows are in a ySQL database table, you need to use aggregate function COUNT(*).The syntax is as followsSELECT COUNT(*) FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table CountRowsDemo    - > (    - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    - > Name varchar(20)    - > ); Query OK, 0 rows affected (0.78 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into CountRowsDemo(Name) values(NULL); Query OK, 1 row affected (0.15 sec) mysql> ...

Read More

The toArray() method of Java AbstractCollection class

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 182 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 absCollection = new ArrayList(); absCollection.add("Laptop"); absCollection.add("Tablet"); absCollection.add("Mobile"); absCollection.add("E-Book Reader");Now, use the toArray() method to return the elements in the form of an arrayObject[] myArr = absCollection.toArray();The following is an example to implement AbstractCollection toArray() method in JavaExample Live Demoimport java.util.ArrayList; import java.util.AbstractCollection; public class Demo {    public static void main(String[] ...

Read More

Search a string with special characters in a MongoDB document?

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 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"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c987bdb330fd0aa0d2fe4b2") } >db.searchDocumentWithSpecialCharactersDemo.insertOne({"UserId":"Doe$John999", "UserFirstName":"John", "UserLastName":"Doe"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c987bee330fd0aa0d2fe4b3") } >db.searchDocumentWithSpecialCharactersDemo.insertOne({"UserId":"Miller$David555", "UserFirstName":"David", "UserLastName":"Miller"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c987c01330fd0aa0d2fe4b4") }Following is the query to display all documents from a collection with the help of ...

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 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 - > ( - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, - > Email varchar(128), - > PhoneNumber varchar(15), - > Country varchar(30), - > Platform varchar(40) - > ); Query OK, 0 ...

Read More

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

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 585 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,       "empty" : false    },    {       "name" : "config",       "sizeOnDisk" : 98304,       "empty" : false    },    {       "name" : "local",       "sizeOnDisk" : 73728,       "empty" : false ...

Read More

Change a MySQL Column datatype from text to timestamp?

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 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    - > (    - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    - > Source text    - > ); Query OK, 0 rows affected (0.44 sec)Here is the description of table using DESC command.The syntax is as followsDESC yourTableName;The query is as followsmysql> desc textTotimestampdemo;The following is the output+--------+---------+------+-----+---------+----------------+ | ...

Read More
Showing 631–640 of 810 articles
« Prev 1 62 63 64 65 66 81 Next »
Advertisements