Java Lambda - Exercises, Practice, Solution
Java Lambda [25 exercises with solution]
[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]
Java 8 introduces several new language features designed to make it easier to write such blocks of code-the key feature being lambda expressions, also colloquially referred to as closures or anonymous methods. A lambda expression is just a shorter way of writing an implementation of a method for later execution.
1. Write a Java program to implement a lambda expression to find the sum of two integers.
2. Write a Java program to implement a lambda expression to check if a given string is empty.
3. Write a Java program to implement a lambda expression to convert a list of strings to uppercase and lowercase.
4. Write a Java program to implement a lambda expression to filter out even and odd numbers from a list of integers.
5. Write a Java program to implement a lambda expression to sort a list of strings in alphabetical order.
6. Write a Java program to implement a lambda expression to find the average of a list of doubles.
7. Write a Java program to implement a lambda expression to remove duplicates from a list of integers.
8. Write a lambda expression to implement a lambda expression to calculate the factorial of a given number.
9. Write a Java program to implement a lambda expression to create a lambda expression to check if a number is prime.
10. Write a Java program to implement a lambda expression to concatenate two strings.
11. Write a Java program to implement a lambda expression to find the maximum and minimum values in a list of integers.
12. Write a Java program to create a lambda expression to multiply and sum all elements in a list of integers.
13. Write a Java program to implement a lambda expression to count words in a sentence.
14. Write a Java program to implement a lambda expression to check if a given string is a palindrome.
15. Write a Java program to implement a lambda expression to calculate the sum of squares of all odd and even numbers in a list.
16. Write a Java program to implement a lambda expression to check if a list of strings contains a specific word.
17. Write a Java program to implement a lambda expression to find the length of the longest and smallest string in a list.
18. Write a Java program to implement a lambda expression to check if a given number is a perfect square.
19. Write a Java program to implement a lambda expression to find the second largest and smallest element in an array.
20. Write a Java program to implement a lambda expression to sort a list of objects based on a specific attribute.
21. Write a Java program to implement a lambda expression to calculate the sum of all prime numbers in a given range.
22. Write a Java program to implement a lambda expression to check if a list of strings are all uppercase or all lowercase or mixedcase.
23. Write a Java program to implement a lambda expression to find the average length of strings in a list.
24. Write a Java program to implement a lambda expression to find the largest prime factor of a given number.
25. Write a Java program to implement a lambda expression to convert an integer to their corresponding binary representation.
More to Come !
* To run the code mouse over on Result panel and click on 'RERUN' button.*
Java Code Editor
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/java-exercises/lambda/index.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics