switch-case statement considerations

switch-case notes:

    switch(A), the value of A in parentheses can only be an integer or a numeric type that can be converted to an integer, such as byte, short, int, char, and enumeration; it should be emphasized that: long and String types are Does not work on switch statements .

     case B: C; case is a constant expression, that is to say, the value of B can only be a constant (a final constant needs to be defined, the reason will be described in detail later) or int, byte, short, char (such as 1, 2 , 3, 200000000000 (note that this is an integer)), if you need to write an expression or variable here, then you need to add single quotes ; the statement after the case can be without braces, that is, C does not need to use braces enclosed in parentheses;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325402670&siteId=291194637