Q
qazmlp1209
enum firstEnum
{
ONE, TWO, THREE
}
enum secondEnum
{
ONE, TWO, THREE
}
public static void main( String args[] )
{
firstEnum firstEnumVal = firstEnum.ONE ;
secondEnum secondEnumVal = (secondEnum) firstEnumVal ;//Error is
reported here.
}
As you can see above, the integer values of the constants of both the
enums are assumed to be same(coincidentally the name also in the above
example). In that case, how exactly I can convert from one enum type to
another?
{
ONE, TWO, THREE
}
enum secondEnum
{
ONE, TWO, THREE
}
public static void main( String args[] )
{
firstEnum firstEnumVal = firstEnum.ONE ;
secondEnum secondEnumVal = (secondEnum) firstEnumVal ;//Error is
reported here.
}
As you can see above, the integer values of the constants of both the
enums are assumed to be same(coincidentally the name also in the above
example). In that case, how exactly I can convert from one enum type to
another?