public static ArrayList<Employee> getPersonsBySlaraYAndId(ArrayList<Employee> allPersons) { ArrayList<Employee> persons = new ArrayList<>(); for (Employee p : allPersons) { if (p.getSalary() > 5000 && p.getId() > 2) { persons.add(p); } } return persons; }