The document contains 26 Java 8 coding questions focused on using Streams and Lambda expressions. Each question includes a code snippet that demonstrates how to perform specific tasks such as separating odd and even numbers, removing duplicates, calculating frequencies, and more. The questions cover a range of topics from basic operations to more complex algorithms like finding anagrams and generating Fibonacci series.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2 views4 pages
Updated Java 8 Coding Questions
The document contains 26 Java 8 coding questions focused on using Streams and Lambda expressions. Each question includes a code snippet that demonstrates how to perform specific tasks such as separating odd and even numbers, removing duplicates, calculating frequencies, and more. The questions cover a range of topics from basic operations to more complex algorithms like finding anagrams and generating Fibonacci series.
s1 = Stream.of(s1.split("")).map(String::toUpperCase).sorted().collect(Collectors.joining()); s2 = Stream.of(s2.split("")).map(String::toUpperCase).sorted().collect(Collectors.joining()); // If s1 and s2 are equal, they are anagrams.
11. Merge Two Unsorted Arrays Into Single Sorted Array Without Duplicates IntStream.concat(Arrays.stream(a), Arrays.stream(b)) .sorted().distinct().toArray();
12. Three Max & Min Numbers From The List
// Min 3 Numbers listOfIntegers.stream().sorted().limit(3).forEach(System.out::println); // Max 3 Numbers listOfIntegers.stream().sorted(Comparator.reverseOrder()).limit(3).forEach(System.out::println);
listOfStrings.stream().skip(listOfStrings.size() - 1).findFirst().get(); 25. Age Of Person In Years LocalDate birthDay = LocalDate.of(1985, 01, 23); LocalDate today = LocalDate.now(); System.out.println(ChronoUnit.YEARS.between(birthDay, today));
26. Fibonacci Series
Stream.iterate(new int[]{0, 1}, f -> new int[]{f[1], f[0] + f[1]}) .limit(10) .map(f -> f[0]) .forEach(i -> System.out.print(i + " "));
Calculation of Average Mutual Information (AMI) and False-Nearest Neighbors (FNN) For The Estimation of Embedding Parameters of Multidimensional Time Series in Matlab