2:50 am - Friday April 19, 2019

LinkedHashMap example program by using Boolean contain() method

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

/**

*@author :CandidJava.com

*@descriptions : This program explain the function and use of containsValue() method

*/

/**LinkedHashMap contains*/

import java.util.*;

import java.util.LinkedHashMap;

class LinkedHashMapcontains{

public static void main(String args[]) {

//creating LinkedHashMap Object

LinkedHashMap lhm = new LinkedHashMap();

System.out.println("Initial LinkedHashMap:"+lhm.size());

lhm.put(1, "mani");

lhm.put(6, "karthi");

lhm.put(5, "Bala");

lhm.put(4, "Anand");

lhm.put(3, "candid");

//containsValue() method is used to check that the list contains the value using Boolean functin

boolean b=lhm.containsValue("karthi");

if(b==true)

System.out.println("sucessfully added");

else

System.out.println("failed");

}

}

/**output

D:\CandidJava\Util\LinkedHashMap>javac LinkedHashMapcontains.java

Note: LinkedHashMapcontains.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

D:\CandidJava\Util\LinkedHashMap>java LinkedHashMapcontains

Initial LinkedHashMap:0

sucessfully added

*/

BACK

Filed in: Z-A All Java Codes

No comments yet.

Leave a Reply