This Java code demonstrates the usage of EnumSet and foreach loop. Here's a brief explanation of the code:
import java.util.*; public class Foreach_Loop { public static void main(String[] args) { EnumSet < WEEKDAY > item = EnumSet.noneOf(WEEKDAY.class); item.add(WEEKDAY.Wednesday); item.add(WEEKDAY.Friday); item.add(WEEKDAY.Tuesday); System.out.print("Elements of EnumSet : "); for (WEEKDAY i: item) { System.out.print(i+" "); } } } enum WEEKDAY { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday };
Elements of EnumSet : Tuesday Wednesday Friday
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions