Lab 11-1 Impromptu Pipelines – Intro to Lambda Streams
OOPDA Lab 11-1 Impromptu Pipelines – Intro to Lambda Streams This is an outline of an instructor-led demo to introduce Pipelines • • • Create class Info with attributes name:String, and age:int. a. Add constructor, accessors and toString() In a main method of class Tester, create an ArrayList people. Add a bunch of new Info’s to the people list… Demonstration activities: 1. Use forEach() to SOP [invoking toString()] people.forEach(p-> System.out.println(p) ); 2. Make a stream people.stream() .forEach(p-> System.out.println(p)); 3. Add a filter people.stream() .filter( p-> p.getAge() > 21 ) .forEach(p-> System.out.println(p)); 4. Map people.stream() .map( p-> p.getAge() ) //new stream created – of just ints .forEach(p-> System.out.println(p)); 5. Reduce int totAges = people.stream() .map( p-> p.getAge() ) .reduce(0, (total, age) -> total + age); System.out.println(“Tot ages: “ + totAges); Lab Deliverable: Submit zip of eclipse project, plus a screen-shot showing last few lines of your output Lab11-1 rev SU20 Intro to Lambdas/Pipelines 3/26/2022 10:59 AM
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.
