Monday, 19 January 2015

Java : Collection Framework : HashMap (Size)


Click here to watch in Youtube : 
https://www.youtube.com/watch?v=4MfZ-W_9rzA&list=UUhwKlOVR041tngjerWxVccw

HashMapExample.java
import java.util.HashMap;

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

        HashMap<Integer, String> hashMap = new HashMap<Integer, String>();

        hashMap.put(1, "Apple");
        hashMap.put(2, "Ball");
        hashMap.put(3, "Cat");

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

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

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

    }
}
Output
hashMap : {1=Apple, 2=Ball, 3=Cat}

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