3:35 am - Friday May 26, 2017

Clear all values from the hashMap void clear()

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

BACK

                     This method is used to remove all of the mappings from this map. It removes all the key and values that are all created in a specified map.

Example Program


import java.util.HashMap;

import java.util.Set;

public class Key 
{

	public static void main(String args[])

	{

		HashMap hp = new HashMap();

		hp.put("1", "yui");

		hp.put("2", "gth");

		hp.put("3", "qwe");

		Set keyset = hp.keySet();

		System.out.println("The values are:" + keyset);

	}

}


Output

   Name=Akshara

   Qualification=MCA

   Skill Set=C,C++,Java

   HashMap Values{Name=Akshara, Qualification=MCA, SkillSet=C,C++,Java}

   Now the hashmap values:{}

BACK

Filed in: Java Examples

Comments are closed.