Create new Tree Map - Java java.util

Java examples for java.util:Collection Creation

Description

Create new Tree Map

Demo Code


//package com.java2s;

import java.util.Comparator;

import java.util.Map;

import java.util.SortedMap;

import java.util.TreeMap;

public class Main {
    public static void main(String[] argv) {
        System.out.println(newTreeMap());
    }//from w  ww. jav a  2 s  . c o m

    public static <K, V> TreeMap<K, V> newTreeMap() {
        return new TreeMap<K, V>();
    }

    public static <K, V> TreeMap<K, V> newTreeMap(
            final Comparator<? super K> c) {
        return new TreeMap<K, V>(c);
    }

    public static <K, V> TreeMap<K, V> newTreeMap(
            final Map<? extends K, ? extends V> m) {
        return new TreeMap<K, V>(m);
    }

    public static <K, V> TreeMap<K, V> newTreeMap(
            final SortedMap<K, ? extends V> m) {
        return new TreeMap<K, V>(m);
    }
}

Related Tutorials