Found 7442 Articles for Java

DoubleStream.Builder accept() method in Java

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

142 Views

The accept() method of the DoubleStream class in Java adds an element to the stream being built.The syntax is as follows −void accept(double ele)Here, ele is the element to be inserted into the stream.To use the DoubleStream.Builder class in Java, import the following package −import java.util.stream.DoubleStream;The following is an example to implement DoubleStream.Builder() accept() method in Java −Example Live Demoimport java.util.stream.DoubleStream; public class Demo {    public static void main(String[] args) {       DoubleStream.Builder builder = DoubleStream.builder();       builder.accept(12.9);       builder.accept(25.6);       builder.accept(35.8);       builder.accept(43.9);       builder.accept(56.3);   ... Read More

DoubleStream builder() method in Java

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

112 Views

The builder() method of the DoubleStream class returns a builder for a DoubleStream.The syntax is as follows −static DoubleStream.Builder builder()To use the DoubleStream class in Java, import the following package −import java.util.stream.DoubleStream;The following is an example to implement DoubleStream builder() method in Java −Example Live Demoimport java.util.stream.Stream; import java.util.stream.DoubleStream; public class Demo {    public static void main(String[] args) {       DoubleStream doubleStream = DoubleStream.builder().add(15.9).build();       doubleStream.forEach(System.out::println);    } }Output15.9

ArrayBlockingQueue contains() method in Java

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

157 Views

The contains() method of the ArrayBlockingQueue class is used to search for an element in the queue. If the element exist in the queue, TRUE is returned.The syntax is as follows −boolean contains(Object ob)Here, ob is the element to be searched.To work with ArrayBlockingQueue class, you need to import the following package −import java.util.concurrent.ArrayBlockingQueue;The following is an example to implement contains() method of Java ArrayBlockingQueue class −Example Live Demoimport java.util.concurrent.ArrayBlockingQueue; public class Demo {    public static void main(String[] args) throws InterruptedException {       ArrayBlockingQueue q = new ArrayBlockingQueue(10);       q.add(200);       q.add(310);   ... Read More

Search for a value in Java LabelValue Tuple

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

112 Views

To search for a value in the LabelValue tuple in Java, use the contains() method. It returns a boolean value. TRUE is returned if the value exists, else FALSE is the return value. Let us first see what we need to work with JavaTuples. To work with LabelValue class in JavaTuples, you need to import the following package −import org.javatuples.LabelValue;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide ... Read More

Get the size of the LabelValue Tuple in Java

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

189 Views

To get the size of the LabelValue tuple in Java, use the getSize() method. Let us first see what we need to work with JavaTuples. To work with LabelValue class in JavaTuples, you need to import the following package −import org.javatuples.LabelValue;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples −Steps − How to run JavaTuples program in EclipseThe following is an ... Read More

Set LabelValue value and label in Java

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

337 Views

To set LabelValue value and label in Java, use the setLabel() and setValue() methods. Let us first see what we need to work with JavaTuples. To work with LabelValue class in JavaTuples, you need to import the following package −import org.javatuples.LabelValue;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples −Steps − How to run JavaTuples program in EclipseThe following is an ... Read More

The indexOf() method of AbstractSequentialList in Java

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

124 Views

The indexOf() method is inherited from the AbstractList class. It is used to return the index of the first occurrence of the specified element in this list. If the list is empty, it returns -1.The syntax is as follows −public int indexOf(Object ele)Here, ele is the element for which you want the index.To work with the AbstractSequentialList class in Java, you need to import the following package −import java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList indexOf() method in Java −Example Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo {    public static void main(String[] args) {       ... Read More

LocalTime plusSeconds() method in Java

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

74 Views

An immutable copy of a LocalTime object where some seconds are added to it can be obtained using the plusSeconds() method in the LocalTime class in Java. This method requires a single parameter i.e. the number of seconds to be added and it returns the LocalTime object with the added seconds.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo {    public static void main(String[] args) {       LocalTime lt = LocalTime.now();       System.out.println("The current LocalTime is: " + lt);       System.out.println("The LocalTime with 5 seconds added is: ... Read More

LocalTime plusMinutes() method in Java

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

79 Views

An immutable copy of a LocalTime object where some minutes are added to it can be obtained using the plusMinutes() method in the LocalTime class in Java. This method requires a single parameter i.e. the number of minutes to be added and it returns the LocalTime object with the added minutes.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo {    public static void main(String[] args) {       LocalTime lt = LocalTime.now();       System.out.println("The current LocalTime is: " + lt);       System.out.println("The LocalTime with 15 minutes added is: ... Read More

LocalTime toNanoOfDay() method in Java

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

75 Views

The time in the form of nanoseconds of the day can be obtained using the toNanoOfDay() method in the LocalTime class in Java. This method requires no parameters and it returns the time in the form of nanoseconds of the day.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main {    public static void main(String[] args) {       LocalTime lt = LocalTime.parse("05:15:30");       System.out.println("The LocalTime is: " + lt);       System.out.println("The nanoseconds of the day are: " + lt.toNanoOfDay());    } }OutputThe LocalTime is: 05:15:30 The nanoseconds of ... Read More

Advertisements