1) Given a list of integers, separate odd and even numbers?
List<Integer> listOfIntegers = Arrays.asList(71, 18, 42, 21, 67, 32, 95, 14, 56,
87);
2) How do you remove duplicate elements from a list using Java 8 streams?
List<String> listOfStrings = Arrays.asList("Java", "Python", "C#", "Java",
"Kotlin", "Python");
3)How do you find frequency of each character in a string using Java 8 streams?
String inputString = "Java Concept Of The Day";
4)How do you find frequency of each element in an array or a list?
List<String> stationeryList = Arrays.asList("Pen", "Eraser", "Note Book", "Pen",
"Pencil", "Stapler", "Note Book", "Pencil");
5) How do you sort the given list of decimals in reverse order?
List<Double> decimalList = Arrays.asList(12.45, 23.58, 17.13, 42.89, 33.78, 71.85,
56.98, 21.12);
6)Given a list of strings, join the strings with ‘[‘ as prefix, ‘]’ as suffix and
‘,’ as delimiter?
List<String> listOfStrings = Arrays.asList("Facebook", "Twitter", "YouTube",
"WhatsApp", "LinkedIn");
7) Given a list of integers, find maximum and minimum of those numbers?
List<Integer> listOfIntegers = Arrays.asList(45, 12, 56, 15, 24, 75, 31, 89);
8)How do you get three maximum numbers and three minimum numbers from the given
list of integers?
List<Integer> listOfIntegers = Arrays.asList(45, 12, 56, 15, 24, 75, 31, 89);
9)Find the longest string in a list of strings using Java streams:
List<String> strings = Arrays
.asList("apple", "banana", "cherry", "date", "grapefruit");
10) Calculate the average age of a list of Person objects using Java streams:
List<Person> persons = Arrays.asList(
new Person("Alice", 25),
new Person("Bob", 30),
new Person("Charlie", 35)
);
11)Merge two sorted lists into a single sorted list using Java streams:
List<Integer> list1 = Arrays.asList(1, 3, 5, 7, 9);
List<Integer> list2 = Arrays.asList(2, 4, 6, 8, 10);