5:16 pm - Sunday October 22, 2017

Verify LinkedHashMap is Empty boolean isEmpty()

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 public boolean isEmpty() checks whether the map is empty or not. If the map is empty it returns true,Otherwise it returns false.

Example Program


import java.util.LinkedHashMap;

public class LinkedHashMapisEmpty

 {

	public static void main(String args[]) 
   
     {

		LinkedHashMap lhm = new LinkedHashMap();

		lhm.put(1, "Add");

		lhm.put(6, "Sub");

		lhm.put(5, "Mul");

		lhm.put(4, "Div");

		lhm.put(3, "Expo");

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

		System.out.println(" Is Empty :" + lhm.isEmpty());

	}

  }


Output

       Initial LinkedHashMap:5

       Is Empty :false

BACK

Filed in: Java Examples

Comments are closed.