Friday, 30 January 2015

Java : Collection Framework : TreeMap (Default Constructor)


Click here to watch in Youtube : 
https://www.youtube.com/watch?v=rFwZRaSSJMI&list=UUhwKlOVR041tngjerWxVccw

TreeMapExample.java
import java.util.TreeMap;

/*
 * Example of TreeMap() Constructor.
 */
public class TreeMapExample
{
    public static void main( String[] args )
    {
        /*
         * Constructs a new, empty tree map, using the natural ordering of its
         * keys. All keys inserted into the map must implement the Comparable
         * interface.
         */
        TreeMap<Integer, String> treeMap = new TreeMap<Integer, String>();

        treeMap.put(1, "Cat");
        treeMap.put(3, "Dog");
        treeMap.put(4, "Apple");
        treeMap.put(2, "Ball");
        

        System.out.println("treeMap : " + treeMap + "\n");

    }
}
Output
treeMap : {1=Cat, 2=Ball, 3=Dog, 4=Apple}
To Download TreeMapDemoDefaultCons Project Click the below link
https://sites.google.com/site/javaee4321/java-collections/TreeMapDemoDefaultCons.zip?attredirects=0&d=1

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • No comments:

    Post a Comment

    Google+ Followers

    Google+ Badge