Tuesday 27 January 2015

Java : Collection Framework : LinkedHashMap (ContainsValue)


Click here to watch in Youtube : 
https://www.youtube.com/watch?v=7SK-u8-NDsw&list=UUhwKlOVR041tngjerWxVccw

LinkedHashMapExample.java
import java.util.LinkedHashMap;

/*
 * Example of containsValue(Object value) method.
 */
public class LinkedHashMapExample
{
    public static void main( String[] args )
    {

        LinkedHashMap<Integer, String> linkedHashMap = new LinkedHashMap<Integer, String>();

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

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

        /*
         * Returns true if this map maps one or more keys to the specified
         * value.
         */
        boolean isValueExist = linkedHashMap.containsValue("Ball");

        System.out.println("isValue 'Ball' Exist : " + isValueExist);

        isValueExist = linkedHashMap.containsValue("Dog");

        System.out.println("isValue 'Dog' Exist : " + isValueExist);

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

isValue 'Ball' Exist : true
isValue 'Dog' Exist : false
To Download LinkedHashMapDemoContainsValue Project Click the below link
https://sites.google.com/site/javaee4321/java-collections/LinkedHashMapDemoContainsValue.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