Commit a0b6211e authored by Sri Kala Gottumukkala's avatar Sri Kala Gottumukkala

A New Task

parents
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/twentysevenfirstweekendtask.iml" filepath="$PROJECT_DIR$/twentysevenfirstweekendtask.iml" />
</modules>
</component>
</project>
\ No newline at end of file
package Weekedtask;
/**
* taking a class Employee with employee attributes id, name, salary
*/
public class Employee {
int id;
String name;
int age;
double salary;
/**
* taking parameterized constructor of employee id , name, age, salary
*/
public Employee(int id, String name, int age, double salary) {
this.id = id;
this.name = name;
this.age = age;
this.salary = salary;
}
/**
* generating getters and setters to employee
*/
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
/**
* to represent an object of employee class as a String
*/
@Override
public String toString() {
return "Employee{" +
"id=" + id +
", name='" + name + '\'' +
", age=" + age +
", salary=" + salary +
'}';
}
}
package Weekedtask;
import java.util.ArrayList;
import java.util.List;
public class SortingEmployee{
public static void main(String[] args) {
List<Employee> employees = new ArrayList<Employee>();
employees.add(new Employee(10, "Ramesh", 42, 400000));
employees.add(new Employee(20, "Santosh",41 , 350000));
employees.add(new Employee(30, "Sanjay", 41, 450000));
employees.add(new Employee(40, "Pramod", 29, 500000));
employees.stream().sorted((a1,a2)-> (int) (a2.getSalary()-a1.getSalary())).filter(a1->a1.getAge()>40).forEach((a1)->System.out.println(a1));
}
}
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment