Krantik Chavan has Published 308 Articles

What is the IntStream.Builder accept() method in Java

Krantik Chavan

Krantik Chavan

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

87 Views

Insert an element into IntStream using the IntStream.Builder accept() method. It adds element to the stream being built.The syntax is as follows:void accept(int t)Here, parameter t is the input argument.The elements are inserted as shown below in the stream:builder.accept(10); builder.accept(15); builder.accept(25); builder.accept(39); builder.accept(45);The following is an example to implement IntStream.Builder ... Read More

Why are Prepared Statements in JDBC faster than Statements? Explain?

Krantik Chavan

Krantik Chavan

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

467 Views

While executing statements using Statement object, especially insert statements, each time a query is executed the whole statement is compiled and executed again and again where, the only difference among these statements is the values of the statements.Whereas, prepared statement is a precompiled statement i.e. the query is compiled and ... Read More

IntStream.Builder add() method in Java

Krantik Chavan

Krantik Chavan

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

99 Views

To insert element into the stream, you need to use the add() method of the IntStream.Builder.The syntax is as follows:default IntStream.Builder add(int t)Here, parameter t is the element to be inserted.Declare IntStream.Builder:IntStream.Builder builder = IntStream.builder();Add some elements to the Builder using add() method:builder.add(10); builder.add(25); builder.add(33); builder.add(42);The following is an example ... Read More

What are the advantages and limitations of JDBC PreparedStatement?

Krantik Chavan

Krantik Chavan

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

2K+ Views

Following are the advantages of the prepared statement:By avoiding multiple compilation and execution of statements, prepared statements perform faster.Using prepared statements, we can insert values to advanced datatypes such as BLOB, CLOB, OBJECT easily with the help of the setter methods provided by the PreparedStatement interface.By providing setter method to ... Read More

StringJoiner merge() method in Java 8

Krantik Chavan

Krantik Chavan

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

223 Views

The merge() method of the StringJoiner class in Java 8 is used to merge the contents of the StringJoiner str, which is passed as a parameter. The content gets added as the next element.The syntax is as follows:public StringJoiner merge(StringJoiner str)Here, str is the StringJoiner content to be merged.To work ... Read More

The remove() method of Java AbstractCollection class

Krantik Chavan

Krantik Chavan

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

361 Views

If you want to remove an element from the AbstractCollection classs, use the remove() method. It returns TRUE if the elements requested to be removed is successfully removed from the collection.The syntax is as follows:public boolean remove(Object ob)Here, ob is the element to be removed the from this Collection. Whereas, ... Read More

What is Octet class in JavaTuples?

Krantik Chavan

Krantik Chavan

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

86 Views

An Octetclass is a Tuple of 8 element. It is in the JavaTuples library. The following is the declaration of the Octet class:public final class Octet extends Tuple implements IValue0, IValue1, IValue2, IValue3, IValue4, IValue5, IValue6, IValue7Let us first see what we need to work with JavaTuples. To work with ... Read More

DoubleStream toArray() method in Java

Krantik Chavan

Krantik Chavan

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

79 Views

The toArray() method returns an array containing the elements of this stream.The syntax is as follows:double[] toArray()To use the DoubleStream class in Java, import the following package:import java.util.stream.DoubleStream;Create DoubleStream and add some elements:DoubleStream doubleStream = DoubleStream.of(20.7, 30.5, 45.9, 60.2, 75.9, 88.3, 95.2);Now, use the toArray() method to return an array ... Read More

C++ Program to Implement the Schonhage-Strassen Algorithm for Multiplication of Two Numbers

Krantik Chavan

Krantik Chavan

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

970 Views

Schonhage-Strassen Algorithm is used to multiply two numbers. The SchonhageStrassen algorithm is an asymptotically fast multiplication algorithm for large integers. In practice the Schonhage-Strassen algorithm starts to outperform older methods like karatsuba and Toom-CooK for numbers beyond 2215 to 2217 (10, 000 to 40, 000 decimal) digits.AlgorithmBegin    function noOfDigit( ... Read More

C++ Program to Implement Russian Peasant Multiplication

Krantik Chavan

Krantik Chavan

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

394 Views

Russian Peasant algorithm to multiply two numbers. It is a quick algorithm to calculate multiplication of two long numbers.AlgorithmBegin    Russianpeasant(num1, num2)    Int result=0    while (num2 > 0)       if (num2 and 1)          result = result + n;         ... Read More

Advertisements