isEmpty(): This method is available in java.util.EnumMap class of Java.
Syntax:
boolean java.util.AbstractMap.isEmpty()
This method returns true if this map contains no key-value mappings.
Parameters: NA
Returns: true if this map contains no key-value mappings.
Exceptions: NA
Approach
Java
import java.util.EnumMap;public class EnumMapisEmpty {public enum Colour {RED, GREEN, YELLOW, ORANGE};public static void main(String[] args) {EnumMap<Colour, String> enumMap =new EnumMap<Colour, String>(Colour.class);enumMap.put(Colour.RED, "Red");enumMap.put(Colour.GREEN, "Green");enumMap.put(Colour.YELLOW, "Yellow");enumMap.put(Colour.ORANGE, "Orange");System.out.println(enumMap.isEmpty());}}
Output:
false
No comments:
Post a Comment