VOOZH about

URL: https://www.geeksforgeeks.org/java/map-isempty-method-in-java-with-examples/

⇱ Map isEmpty() Method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Map isEmpty() Method in Java with Examples

Last Updated : 2 Jan, 2019
This method is used to check if a map is having any entry for key and value pairs. If no mapping exists, then this returns true. Syntax:
boolean isEmpty()
Parameters: This method has no argument. Returns: This method returns True if the map does not contain any key-value mapping. Below programs show the implementation of int isEmpty() method. Program 1:
Output:
{}
true
Program 2: Below is the code to show implementation of hashCode().
Output:
{1=One, 3=Three, 5=Five, 7=Seven, 9=Ninde}
false
Reference: Oracle Docs
Comment