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!".
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
1. 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.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps