Notice
Recent Posts
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 깃허브
- SESSION
- springboot
- 깃허브 간단요약
- java
- 알고리즘
- jquery
- EL태그
- Spring
- 오라클
- 제이쿼리
- Eclipse
- 마이바티스
- 셋업
- MySQL
- 면접
- 설정
- 설치
- 버튼
- 자바스크립트
- 필터체인
- 폼태그
- jsp 내부객체
- 스프링
- html
- jstl
- 이클립스
- 자바
- Oracle
- jsp
Archives
- Today
- Total
은은하게 코드 뿌시기
컬렉션프레임웍(Collections Framework) - TreeSet 본문
728x90
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
|
package coding;
import java.util.*;
class code1_Treeset {
public static void main(String[] args) {
System.out.println("Treeset test");
//중복되지않는 데이터를 허용하지않는 트리형구조.
int[] arr1= {1,2,30,5,4,7,8,10,2,9,10,11,13,17,20,22};
TreeSet treeset = new TreeSet();
for (int i=0; i<arr1.length;i++) {
treeset.add(arr1[i]);
}
System.out.println("11보다 작은값 " + treeset.headSet(new Integer(11)));
System.out.println("11보다 큰값 " + treeset.tailSet(new Integer(11)));
System.out.println("제일작은값 " + treeset.pollFirst());
System.out.println("제일큰값 " + treeset.pollLast());
System.out.println("제일 가까운 같은 값" + treeset.floor(21));
System.out.println("작은것들중에 제일가까운값" + treeset.floor(21));
System.out.println("큰것들중에 제일가까운값" + treeset.higher(21));
System.out.println("포함여부 " + treeset.contains(22));
//clone 복제
//clear 초기화
//ceiling 같은 객체 반환
//toArray() 배열ㄹ로반환
//size 크기
//remove 지정된객체삭제
//first 정렬된 데이터의 첫번쨰 객체
//last 정렬된 데이터의 마지막 객체
//treeset.descendingIterator() 역순으로 반환
}
}
|
cs |
728x90
'자바 > Collections Framework' 카테고리의 다른 글
컬렉션프레임웍(Collections Framework) - TreeMap (0) | 2022.10.02 |
---|---|
컬렉션프레임웍(Collections Framework) - HashMap (0) | 2022.10.02 |
컬렉션프레임웍(Collections Framework) - 큐(Queue) (0) | 2022.10.02 |
컬렉션프레임웍(Collections Framework) - 스택(stack) (0) | 2022.10.02 |
컬렉션프레임웍(Collections Framework) - ArrayList (0) | 2022.10.02 |
Comments