Friday 30 January 2015

Java : Collection Framework : TreeMap (Size)


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

TreeMapExample.java
import java.util.TreeMap;

/*
 * Example of size() method.
 */
public class TreeMapExample
{
    public static void main( String[] args )
    {

        TreeMap<Integer, String> treeMap = new TreeMap<Integer, String>();

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

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

        /*
         * Returns the number of key-value mappings in this map.
         */
        int size = treeMap.size();

        System.out.println("size : " + size);

    }
}
Output
treeMap : {1=Cat, 2=Dog, 3=Ball, 4=Apple}

size : 4
To Download TreeMapDemoSize Project Click the below link
https://sites.google.com/site/javaee4321/java-collections/TreeMapDemoSize.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