-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
44 lines (35 loc) · 1.05 KB
/
Test.java
File metadata and controls
44 lines (35 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.interview.medium;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
class EmployeeTest{
private int id;
private String name;
private double salary;
public EmployeeTest(int id, String name, double salary) {
super();
this.id = id;
this.name = name;
this.salary = salary;
}
}
public class Test {
public static void main(String[] args) {
EmployeeTest test1 = new EmployeeTest(1, "Java", 20000);
EmployeeTest test2 = new EmployeeTest(1, "Java", 20000);
EmployeeTest test3 = new EmployeeTest(2, "Python", 30000);
EmployeeTest test4 = test1;
Set<EmployeeTest> set = new HashSet<>();
set.add(test1);
set.add(test2);
set.add(test3);
set.add(test4);
System.out.println(set.size());
List<Integer> list = Arrays.asList(1,4,6,5,8,10,11);
List<Integer> even = list.stream().filter(n->n%2==0).collect(Collectors.toList());
System.out.println(even);
List<Integer> odd = list.stream().filter(n->n%2==0).collect(Collectors.toList());
}
}