본문 바로가기

Anyway

검색하기
Anyway
프로필사진 dyana

  • 분류 전체보기 (35)
    • 3Tier (1)
      • 1차 PrivateProject (1)
      • 2차 PrivateProject (0)
    • Ansible (2)
    • Git (4)
    • Database (7)
    • Java (14)
      • Spring (10)
    • MAC (1)
    • AWS (5)
Guestbook
Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
일 월 화 수 목 금 토
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
more
Archives
Today
Total
관리 메뉴
  • 글쓰기
  • 방명록
  • RSS
  • 관리

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
이전 Prev 1 Next 다음

Blog is powered by kakao / Designed by Tistory

티스토리툴바