How to print Specific enum value from a loop??
I created a Two D array and accessing Enum values through it...
I wanted to assign the 3rd enum value whose ordinal is '2'
to the following rows and coloumn...[1][0] and [2][4]
i tried this,
DnP[1][0] = DnP [2][4] = Periods.Period1;
but it is not working.....i also tried name() function but it is printing all the values.
here is the code....
class Test {
enum Days {Monday,Tuesday,Wednesday,Thursday,Friday}
enum Periods {Period1,Period2,Period3,Period4,Period5}
public static void main (String [] args)
{
String DnP [][] = new String [8][5];
for (Days dys : Days.values())
{
DnP [0][dys.ordinal()] = dys.name();
System.out.print (DnP[0][dys.ordinal()] + "\t ");
}
System.out.println ("\n");
for (Periods pRds : Periods.values())
DnP[1][0] = DnP [2][4] = Periods.Period1;
System.out.print (DnP[1][0]);
}
}