0% found this document useful (0 votes)
8 views2 pages

Java 8 Stream API Examples

The document is a Java program that demonstrates the use of the Stream API to manipulate a list of integers. It filters the list to include only numbers greater than 20 and maps each element by adding 5. Additionally, it shows how to create a stream using Stream.of() and find the minimum value in a stream.

Uploaded by

job.riyasingh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Java 8 Stream API Examples

The document is a Java program that demonstrates the use of the Stream API to manipulate a list of integers. It filters the list to include only numbers greater than 20 and maps each element by adding 5. Additionally, it shows how to create a stream using Stream.of() and find the minimum value in a stream.

Uploaded by

job.riyasingh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

package com.

java8;

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

public class UseOfStreamApi {

public static void main(String[] args) {

// TODO Auto-generated method stub

ArrayList<Integer> a=new ArrayList<Integer>([Link](10,20,30,40,50));

//program to take out the list no greater than 20

List<Integer> collect = [Link]().filter(i->i>20).collect([Link]());

[Link](collect);

//program to take out the list where we are adding 5 to each element in list

List<Integer> collect2 = [Link]().map(i->i+5).collect([Link]());

[Link](collect2);
//define stream with [Link]()

Stream <Integer> s1= [Link](1,2,3,4,5);

[Link](i->[Link](i+" "));

//use of minimum maximum

Stream <Integer> s2= [Link](1,2,3,4,5);

Integer integer = [Link]((o1,o2)->[Link](o2)).get();

[Link]();

You might also like