Question: Write a lambda or method reference for each of the following tasks: a) Write a lambda that can be used in place of the following
Write a lambda or method reference for each of the following tasks: a) Write a lambda that can be used in place of the following anonymous inner class: new IntConsumer() { public void accept(int value) { System.out.printf("%d ", value); } } b) Write a method reference that can be used in place of the following lambda: (String s) -> {return s.toUpperCase();} c) Write a no-argument lambda that implicitly returns the String "Welcome to lambdas!". d) Create a one-parameter lambda that returns the cube of its argument.
Step by Step Solution
3.44 Rating (151 Votes )
There are 3 Steps involved in it
To solve these tasks lets break each problem down and provide the relevant lambda expressions or met... View full answer
Get step-by-step solutions from verified subject matter experts
