George John has Published 1167 Articles

IntStream of() method in Java

George John

George John

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

368 Views

The IntStream class in Java the following two forms of of() methodIntStream of(int t) methodThe following of() method returns a sequential IntStream containing a single element. Here is the syntaxstatic IntStream of(int t)Here, parameter t is the single element.IntStream of(int… values) methodThe following of() method returns a sequentially ordered stream ... Read More

Collectors maxBy() method in Java 8

George John

George John

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

2K+ Views

The maxBy() method of the Collectors class in Java 8 returns a Collector that produces the maximal element according to a given Comparator, described as an Optional.The syntax is as followsstatic Collector maxBy(Comparator

How to change a primary key in MySQL to auto_increment?

George John

George John

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

4K+ Views

To change a primary key to auto_increment, you can use MODIFY command. Let us first create a table.mysql> create table changePrimaryKeyInAutoIncrement    -> (    -> StudentId int not null primary key,    -> StudentName varchar(100),    -> StudentAge int,    -> StudentAddress varchar(100)    -> ); Query OK, 0 ... Read More

Increment a value in a MongoDB nested object?

George John

George John

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

369 Views

To increment a value in nested object, you can use $inc operator. Let us first implement the following query to create a collection with documents>db.incrementValueDemo.insertOne({"StudentName":"Larry", "StudentCountryName":"US", "StudentDetails":[{"StudentSubjectName":"Math", "StudentMathMarks":79}]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c986ca0330fd0aa0d2fe4a2") }Following is the query to display all documents from a collection with the ... Read More

Count value for multiple columns in MySQL?

George John

George John

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

506 Views

To count value for multiple columns, use the CASE statement. Let us first create a table::mysql> create table countValueMultipleColumnsDemo    -> (    -> Value1 int,    -> Value2 int,    -> Value3 int    -> ); Query OK, 0 rows affected (0.62 sec)Following is the query to insert some ... Read More

C++ Program to Check if an UnDirected Graph is a Tree or Not Using DFS

George John

George John

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

163 Views

A graph is a tree if it does not contain any cycle. This is a C++ program to check whether an undirected graph is tree or not.AlgorithmBegin function cyclicUtil() :    A) Mark the current node as visited.    B) Recur for all the vertices adjacent to this vertex.   ... Read More

In a MySQL schema, what is the meaning of “AUTO_INCREMENT=3”

George John

George John

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

227 Views

In MySQL, AUTO_INCREMENT=3 tells that the inserted record will start from 3 not the default 1. Let us first create a sample table and set auto increment to 3:mysql> create table Auto_incrementDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(20)    -> ... Read More

Can MySQL concatenate strings with ||?

George John

George John

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

96 Views

Yes, you can concatenate strings with || in MySQL with the help of sql_mode. Set the sql_mode to PIPES_AS_CONCAT.The syntax is as followsset sql_mode=PIPES_AS_CONCAT;The following is the syntax to concat with the help of ||.SELECT ‘yourValue' || yourColumName AS anyAliasName FROM yourTableName;To understand the above syntax, let us create a ... Read More

MySQL query to select one specific row and another random row?

George John

George John

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

141 Views

To select one specific row and another random row, you can use ORDER BY and RAND(). Let us first create a sample table:mysql> create table oneSpecificRowAndOtherRandom    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(20)    -> ); Query OK, 0 rows affected ... Read More

IntStream anyMatch() method in Java

George John

George John

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

475 Views

The anyMatch() method in the IntStream class in Java returns whether any elements of this stream match the provided predicate.The syntax is as followsboolean anyMatch(IntPredicate predicate)To work with the IntStream class in Java, import the following packageimport java.util.stream.IntStream;Here, the predicate parameter is a stateless predicate to apply to elements of ... Read More

Advertisements