Skip to content

Tag Archives: Java-Stream-programs

Given a stream containing some elements, the task is to get the first element of the Stream in Java. Example: Input: Stream = {“Geek_First”, “Geek_2”,… Read More
Given a stream containing some elements, the task is to get the last element of the Stream in Java. Example: Input: Stream={“Geek_First”, “Geek_2”, “Geek_3”, “Geek_4”,… Read More
Given a stream containing some elements, the task is to find the duplicate elements in this stream in Java. Examples: Input: Stream = {5, 13,… Read More
Given a string and a character, the task is to make a function which counts the occurrence of the given character in the string using… Read More
The Stream API, introduced in Java 8, it is used to process collections of objects. Stream is a sequence of objects, that supports many different… Read More
Given a Parallel Stream in Java, the task is to reverse its elements. Examples: Input: Parallel Stream = {11, 22, 33, 44} Output: {44, 33,… Read More
Given a Stream, the task is to convert this Stream into ArrayList in Java 8. Examples: Input: Stream: [1, 2, 3, 4, 5] Output: ArrayList:… Read More
Given the task is to generate an infinite sequential unordered stream of double in Java. This can be done in following ways: Using DoubleStream.iterate(): Using… Read More
Given the task is to generate an infinite sequential unordered stream of integers in Java. Recommended: Please try your approach on {IDE} first, before moving… Read More
Given a Stream in Java, the task is to iterate over it with the help of indices. Examples: Input: Stream = [G, e, e, k,… Read More
Given a Stream of Arrays in Java, the task is to Flatten the Stream using forEach() method. Examples: Input: arr[][] = {{ 1, 2 },… Read More
Given a Stream of Lists in Java, the task is to Flatten the Stream using forEach() method. Examples: Input: lists = [ [1, 2], [3,… Read More
Given a Stream of Map in Java, the task is to Flatten the Stream using forEach() method. Examples: Input: map = {1=[1, 2], 2=[3, 4,… Read More
Introduced in Java 8, the Stream API is used to process collections of objects. A stream is a sequence of objects that supports various methods… Read More
Given a String, the task is to convert it into a List of Characters in Java. Examples: Input: String = "Geeks" Output: [G, e, e,… Read More