Tuesday, 20 January 2015

Java : Collection Framework : HashMap (Put)

Click here to watch in Youtube : 

import java.util.HashMap;

 * Example of put(K key,V value) method.
public class HashMapExample
    public static void main( String[] args )

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

         * Associates the specified value with the specified key in this map. If
         * the map previously contained a mapping for the key, the old value is
         * replaced.
        hashMap.put(1, "Apple");
        hashMap.put(3, "Cat");
        hashMap.put(2, "Ball");
        System.out.println("hashMap : "+hashMap);

hashMap : {1=Apple, 2=Ball, 3=Cat}
To Download HashMapDemoPut Project Click the below link

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

    Post a Comment