@Data @AllArgsConstructor @NoArgsConstructor public class User { private int id; private String name; private int age; } public class StreamDemo { public static void main(String[] args) { User a1 = new User(1, "a", 22); User a2 = new User(2, "b", 23); User a3 = new User(3, "c", 24); User a4 = new User(4, "d", 25); User a5 = new User(5, "e", 26); User a6 = new User(6, "f", 27); List<User> users = Arrays.asList(a1, a2, a3, a4, a5, a6); users.stream() .filter((n)->{return n.getId()%2==0;}) .filter(user -> {return user.getAge()>23;}) .map(user -> {return user.getName().toUpperCase();}) .sorted((s,s1)->{ return s.compareTo(s1); }) .forEach(System.out::println); }