Lab 11-1 Impromptu Pipelines – Intro to Lambda Streams
Need help with this assignment?Get an original answer from a qualified tutor — from $10/page.
Get it written →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
Get a plagiarism-free answer to this question
Send us your instructions and we’ll match you with the best writer in your subject.
- 100% human-written, zero AI
- Turnitin report included
- Confidential — we never share your data
- Free revisions & refunds