I would like to know whether order of values in Switch matters according to its type e.g. if I have big switch
case with boolean
, short
, long
, float
, etc. - (if BOOLEAN is faster than NULL , will it be faster to put case which can return NULL or is it faster to put case, which will return BOOLEAN?
So I have two questions:
- Is order in Switch case held? (from up to down?)
- Due to performance/speed - does the order of values in case matter?
code snippet:
switch (user){
case Test.CHAR:
return readChar();
case Test.SHORT:
return readShort();
case Test.BOOLEAN:
return readBoolean();
case Test.BYTE:
return readByte();
case Test.INT:
return readInt();
case Test.LONG:
return readLong();
case Test.STRING:
return readString();
}