clone(): This method is available in java.util.EnumMap class of Java.
Syntax:
EnumMap<K, V> java.util.EnumMap.clone()
This method returns a shallow copy of this enum map. The values themselves are not cloned.
Parameters: NA
Returns: a shallow copy of this enum map.
Exceptions: NA
Approach
Java
import java.util.EnumMap;public class EnumMapclone {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");System.out.println(enumMap.clone());}}
Output:
{RED=Red, GREEN=Green, YELLOW=Yellow}
No comments:
Post a Comment