Final public static ints cannot be used in switch statement?

I'm confused. The following code has errors ("..." represents the highlighted code):

int byteOrder = ...;
switch (byteOrder)
{
    case HDF5Constants.H5T_ORDER_BE:
        return ByteOrder.BIG_ENDIAN;
    ...
}

There is an error in the case argument, and Eclipse complains that "case expressions must be constant expressions." I looked at the source file for this, and it has a long list of lines, for example:

final public static int H5T_ORDER_BE = H5.J2C( JH5T_ORDER_BE );

I thought you could use constants final public static intas cases in a switch statement. I'm wrong???

+3
source share
2 answers

, , H5T_ORDER_BE ( ) - ​​ . , 123 ( , ), .

+10

!:-)

case . , .

+7

Source: https://habr.com/ru/post/1713090/


All Articles