Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- enum
- 널포인터에러
- 두개리스트비교
- db
- 권한정책
- Java
- 중복제거
- Annotation
- 리스트합집합
- 리스트차집합
- lightsail
- 리스트비교
- wordpress블로그
- hashset
- AWS
- WordPress
- awsconsole
- postgresql13
- PostgreSQL
- xml
- peer authentication 에러
- anymatch메서드
- 리스트교집합
- Spring
- route53
- list중복제거
- instance생성
- 지옥같은git
- ansible
- mybatis
Archives
- Today
- Total
Anyway
[JAVA] 두 개의 리스트에서 중복 값 제거 HashSet 사용하기
List A = {3}List B = {3,5,6} A와 B의 리스트에서 중복된 값을 제거하고 싶을 때 // 중복 값을 찾기 위해 HashSet 사용HashSet setA = new HashSet(A);HashSet setB = new HashSet(B);// 교집합을 구해 중복된 값 확인HashSet intersection = new HashSet(setA)intersection.retainAll(setB);// 결과 리스트List result = new ArrayList();//A의 중복되지 않은 값 추가 for (Long num : A) { if (!intersection.contains(num)) { result.add(num); }} // B의 중복되지 않은 값 추가 for (L..
Java/Spring
2025. 1. 3. 09:39