본문 바로가기

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
  • WordPress
  • 지옥같은git
  • wordpress블로그
  • 리스트합집합
  • 널포인터에러
  • list중복제거
  • Spring
  • postgresql13
  • xml
  • 리스트차집합
  • lightsail
  • ansible
  • 중복제거
  • anymatch메서드
  • 권한정책
  • awsconsole
  • instance생성
  • 리스트비교
  • mybatis
  • 두개리스트비교
  • Annotation
  • 리스트교집합
  • hashset
  • AWS
  • route53
  • db
  • PostgreSQL
  • peer authentication 에러
  • enum
  • Java
more
Archives
Today
Total
관리 메뉴
  • 글쓰기
  • 방명록
  • RSS
  • 관리

Anyway

[JAVA] 두 개의 리스트에서 차집합 구하기

List A = {1,2,3}List B = {2,3,4} 이렇게 두 개의 리스트가 있을 때 내가 구하고 싶은 것은 A의 차집합니다.  // A 리스트의 차집합을 구하는 함수 생성public static List findDifference(List A, List B) { Set setB = new HashSet(B); return A.stream() .filter(element -> !setB.contains(element)) .collect(Collectors.toList());} stream()을 사용한 것은 A의 요소를 stream으로 처리하여 B에 없는 요소만 필터링하기 위해서다.   >>> 추가로 [합집합]에 대하여List union = new ArrayList..

카테고리 없음 2025. 1. 3. 09:58
이전 Prev 1 Next 다음

Blog is powered by kakao / Designed by Tistory

티스토리툴바