3:26 pm - Monday September 25, 2017

Clear all elements from LinkedHashMap 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

                           The method void clear() clears all the elements from the map. After performing the clear() function the map returns no values .

Example Program


import java.util.LinkedHashMap;

public class LinkedHashMapKeySet {

	public static void main(String[] args) {

		LinkedHashMap lhm = new LinkedHashMap();

		lhm.put("Add", "+");

		lhm.put("Sub", "-");

		lhm.put("Mul", "*");

		System.out.println("Map:" + lhm);

		lhm.clear();

		System.out.println("Map:" + lhm);

	}

}

Output

       Map:{Add=+, Sub=-, Mul=*}

       Map:{}

BACK

Filed in: Java Examples

Comments are closed.