clone(): This method is available in java.util.EnumSet class of Java.
Syntax:
EnumSet<K> java.util.EnumSet.clone()
This method returns a copy of this set.
Parameters: NA
Returns: a copy of this set.
Exceptions: NA
Approach
Java
import java.util.EnumSet;public class EnumSetclone {public enum Colour {RED, GREEN, YELLOW, ORANGE};public static void main(String[] args) {EnumSet<Colour> enumSet = EnumSet.allOf(Colour.class);System.out.println(enumSet.clone());}}
Output:
[RED, GREEN, YELLOW, ORANGE]
No comments:
Post a Comment