Found 34469 Articles for Programming

LongStream noneMatch() method in Java

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

93 Views

The noneMatch() method of the LongStream class in Java returns whether no elements of this stream match the provided predicate.The syntax is as followsboolean noneMatch(LongPredicate predicate)Here, the parameter predicate is a stateless predicate to apply to elements of this stream. However, LongPredicate in the syntax represents a predicate (boolean-valued function) of one long-valued argument.To use the LongStream class in Java, import the following packageimport java.util.stream.LongStream;The method returns true if either no elements of the stream match the provided predicate or the stream is empty. The following is an example to implement LongStream noneMatch() method in JavaExample Live Demoimport java.util.stream.LongStream; public class ... Read More

IntStream peek() method in Java

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

570 Views

The peek() method in the IntStream class in Java returns a stream consisting of the elements of this stream. It additionally performs the provided action on each element as elements are consumed from the resulting stream.The syntax is as followsIntStream peek(IntConsumer action)Here, the parameter action is a non-interfering action to perform on the elements as they are consumed from the stream. The IntConsumer represents an operation that accepts a single int-valued argument and returns no result.The following is an example to implement IntStream peek() method in JavaExample Live Demoimport java.util.*; import java.util.stream.IntStream; public class Demo { public static ... Read More

IntStream asLongStream() method in Java

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

211 Views

The asLongStream() method of the IntStream class returns a LongStream consisting of the elements of this stream, converted to long.The syntax is as followsLongStream asLongStream()Create an IntStream and add some elements in the StreamIntStream intStream = IntStream.of(30, 40, 60, 70, 90, 110, 140, 150);Now, use the asLongStream() method to convert it to longLongStream longStream = intStream.asLongStream();The following is an example to implement IntStream asLongStream() method in JavaExample Live Demoimport java.util.*; import java.util.stream.IntStream; import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { IntStream intStream = IntStream.of(30, 40, 60, 70, 90, ... Read More

DoubleStream distinct() method in Java

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

79 Views

The distinct() method of the DoubleStream class returns a stream consisting of the distinct elements of this stream.The syntax is as followsDoubleStream distinct()To use the DoubleStream class in Java, import the following packageimport java.util.stream.DoubleStream;Create DoubleStream and add some elements to the streamDoubleStream doubleStream = DoubleStream.of(39.8, 78.7, 64.7, 78.7, 47.8, 89.7, 78.7);Now, to get the distinct elements, use the distinct() methoddoubleStream.distinct() The following is an example to implement DoubleStream distinct() method in Java. We have repeated elements in the streamExample Live Demoimport java.util.stream.DoubleStream; public class Demo { public static void main(String[] args) { ... Read More

The remove() method of Java AbstractSequentialList class

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

53 Views

The remove() method of the AbstractSequentialList class removes the element at the specified position in this list.The syntax is as followsE remove(int index)Here, index is the index of the element to be removed. To work with the AbstractSequentialList class in Java, you need to import the following packageimport java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList remove() method in JavaExample Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo { public static void main(String[] args) { AbstractSequentialList absSequential = new LinkedList(); absSequential.add(25); ... Read More

The listIterator() method of Java AbstractSequentialList class

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

63 Views

The listIterator() method of the AbstractSequentialList class returns a list iterator over the elements in this list.The syntax is as followspublic abstract ListIterator listIterator(int index)Here, index is the index of the first element to be returned from the list iterator. The ListIterator here is the iterator for lists.To work with the AbstractSequentialList class in Java, you need to import the following packageimport java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList listIterator() method in JavaExample Live Demoimport java.util.LinkedList; import java.util.ListIterator; import java.util.AbstractSequentialList; public class Demo { public static void main(String[] args) {     AbstractSequentialList absSequential = ... Read More

LocalDate getMonthValue() method in Java

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

91 Views

The month of the year is obtained using getMonthValue() method in the LocalDate class in Java. This method requires no parameter and it returns the month of the year which may be in the range of 1 to 12.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main { public static void main(String[] args) { LocalDate ld = LocalDate.parse("2019-02-14"); System.out.println("The LocalDate is: " + ld); System.out.println("The month is: " + ld.getMonthValue()); ... Read More

LocalDate getEra() method in Java

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

58 Views

The era for a particular LocalDate can be obtained using the getEra() method in the LocalDate class in Java. This method requires no parameters and it returns the era applicable for the LocalDate.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main { public static void main(String[] args) { LocalDate ld = LocalDate.parse("2019-02-14"); System.out.println("The LocalDate is: " + ld); System.out.println("The era is: " + ld.getEra()); } }OutputThe LocalDate is: 2019-02-14 The ... Read More

LocalDate lengthOfMonth() method in Java

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

82 Views

The length of the month in a particular LocalDate is obtained using the method lengthOfMonth() in the LocalDate class in Java. This method requires no parameters and it returns the length of the month in a particular LocalDate i.e. 28, 29, 30 or 31.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main { public static void main(String[] args) { LocalDate ld = LocalDate.parse("2019-02-15"); System.out.println("The LocalDate is: " + ld); System.out.println("The length of the ... Read More

LocalTime minusHours() method in Java

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

108 Views

An immutable copy of a LocalTime object where some hours are subtracted from it can be obtained using the minusHours() method in the LocalTime class in Java. This method requires a single parameter i.e. the number of hours to be subtracted and it returns the LocalTime object with the subtracted hours.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); ... Read More

Advertisements