HTW Berlin Fachbereich 4 Internationaler Studiengang Internationale Medieninformatik (Bachelor) Info 1: Informatik I Winter Term 2022/23 |
Laboratory 5 :
Lambda Functions
|
Pre-lab
This week's lab work is intended help you better understand lambda functions.
Please bring these exercises printed out or written out with you to lab. Please have your name on your page.
P1. If you have a collection called myList, what Java code would you have to write to apply some code to each of the members in the list?
P2. Given the following code:
public void printStudent (Student s) { System.out.println (s.getDetails()); }
What is the equivalent lambda in Java? What syntax variations are possible?
P3. Given the animal-monitoring-v1 example, write pseudo-code for determining how many elephants a particular spotter saw on a particular day.
P4. Given the animal-monitoring-v1 example, write pseudo-code to create a stream containing only those sightings that have a count greater than 0.
Lab assignments are due before your next lab at 22.00. They may, of course, be turned in earlier. You hand them in by preparing the report in PDF and submitting it to Moodle.
Assignment
Seeing Elephants
Writeup
Submit your writeup as your post-lab to the Moodle area by 22.00 of the night before your next lab.