Consider I have created some enums:
public enum Day {
SUN, MON, TUE, WED, THU, FRI, SAT
}
public enum Month {
JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
}
I want to create a method that will accept any type of enum and display all values. So the call would look something like:
showAll(Day);
showAll(Month);
I'm not sure what to pass to the method. My understanding of Generics is rudimentary at best, despite reading the tutorial several times now. Here is some uncompilable code that might illustrate:
public void showAll(EnumType enumType) // <--- not sure what to pass here
{
Enum[] allValues = enumType.values();
// then, loop over the allValues array and I can proceed from here
}
The actual code is needed is for displaying a list of checkboxes to the user where the input is the enum class, and the checkboxes are every enum value.