[Java] 컬렉션 - 셋(Set)
1. 셋(Set) 셋(Set): 중복되지 않는 요소들의 집합 2. 공통 메서드 0) 생성 Set intHSet = new HashSet(); // ⭐️ 간략한 생성 및 초기화 방법들 // 💡 Arrays 클래스 : 배열 관련 각종 기능 제공 Set intHSet2A = new HashSet( Arrays.asList(1, 2, 3, 4, 5) ); // 💡 자바9에서부터 가능 Set intHSet2B = new HashSet( List.of(1, 2, 3, 4, 5) ); Set intHSet2C = new HashSet(); Collections.addAll(ints2C, 1, 2, 3, 4, 5); 1) 값 추가: add, addAll // ⭐️add 메서드로 요소 추가 // 중복된 요소는 추가되지 ..
2023. 10. 21.
[Java] 컬렉션 - 리스트(List)
1. 공통 메서드 0) 생성 List ints = new ArrayList(); // ⭐️ 간략한 생성 및 초기화 방법들 // 💡 Arrays 클래스 : 배열 관련 각종 기능 제공 List ints2A = new ArrayList( Arrays.asList(1, 2, 3, 4, 5) ); // 💡 자바9에서부터 가능 List ints2B = new ArrayList( List.of(1, 2, 3, 4, 5) ); List ints2C = new ArrayList(); Collections.addAll(ints2C, 1, 2, 3, 4, 5); 1) 값 추가: add, addAll // ⭐️add 메서드로 요소 추가 ints.add(11); ints.add(22); ints.add(33); ints.add..
2023. 10. 20.