Type Here to Get Search Results !

Write a program to find greater salary using java8 stream api

0

 class Employee{

int salary;

String name;

String dept;

public Employee(int salary, String name, String dept) {

super();

this.salary = salary;

this.name = name;

this.dept = dept;

}

public int getSalary() {

return salary;

}

public void setSalary(int salary) {

this.salary = salary;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getDept() {

return dept;

}

public void setDept(String dept) {

this.dept = dept;

}



@Override

public String toString() {

return "Employee [salary=" + salary + ", name=" + name + ", dept=" + dept + "]";

}

}

public class reverse {


public static void main(String[] args) {

List<Employee> employeelist=new ArrayList<>();

employeelist.add(new Employee(1000, "Arun", "Eng"));

employeelist.add(new Employee(2000, "Depala", "Math"));

employeelist.add(new Employee(400, "Vijay", "Mil"));

employeelist.add(new Employee(10000, "Varun", "Eng"));

List<Employee> emplyyy=employeelist.stream().

filter(employ->employ.getSalary()>1000).collect(Collectors.toList());

System.out.println(emplyyy.toString());


}

Post a Comment

0 Comments

Recent-post