자바 SortedMap

175.197.192.184 (토론)님의 2021년 10월 18일 (월) 22:01 판 (새 문서: ==개요== ;,map에는 순서가 없으나 sortedmap은 순서가 있음 ;sortedmap은 인터페이스며, 해당 인터페이스를 모두 구현한 클래스로 TreeMap이 있음 *...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

개요[ | ]

,map에는 순서가 없으나 sortedmap은 순서가 있음
sortedmap은 인터페이스며, 해당 인터페이스를 모두 구현한 클래스로 TreeMap이 있음
  • SortedMap을 구현한 TreeMap 예제
import java.util.SortedMap;
import java.util.TreeMap;
class Main {
    public static void main(String[] args) {
        SortedMap<String, Integer> numbers = new TreeMap<>();
        numbers.put("Two", 2);
        numbers.put("One", 1);
        System.out.println("SortedMap: " + numbers);
        System.out.println("First Key: " + numbers.firstKey());
        System.out.println("Last Key: " + numbers.lastKey());
        int value = numbers.remove("One");
        System.out.println("Removed Value: " + value);
    }
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}