Java 6 Saksham
Java 6 Saksham
1. Aim: Develop Java programs using lambda expressions and stream operations for sorting, filtering,
and processing large datasets efficiently.
2. Objective:
• Develop Java programs using lambda expressions and stream operations for sorting, filtering, and
processing large datasets efficiently.
• Implement easy, medium, and hard-level tasks involving sorting employees, filtering and sorting
students, and processing products using streams.
3. Implementation/Code:
a. import java.util.*;
class Employee {
String name; int
age; double salary;
Employee(String name, int age, double salary)
{ this.name = name; this.age = age;
this.salary = salary;
}
@Override public String toString() { return
name + " - Age: " + age + ", Salary: " + salary;
}
}
public class EmployeeSort { public static void
main(String[] args) { List<Employee>
employees = Arrays.asList( new
Employee("Ayush", 20, 90000), new
Employee("Vinay", 22, 100000),
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
4. Output:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
5. Learning Outcome:
• Understand and implement lambda expressions for sorting objects in a list based on
different attributes.
• Utilize Java Streams API to perform operations like filtering, sorting, and mapping
efficiently on large datasets.
• Learn Comparator and method references to simplify object comparisons for sorting.
• Apply grouping and aggregation functions using Collectors.groupingBy() and
Collectors.maxBy() for processing categorized data.
• Gain hands-on experience in computing statistical values like the average from a dataset
using mapToDouble() and average().
• Improve code efficiency and readability by using functional programming techniques in
Java.