Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - The switch statement is followed by a parenthesis (). What's the use?
The switch statement is followed by a parenthesis (). What's the use?
The judgment condition of switch can only be equal to, so the accuracy of data type is required.

Character type, Boolean type and enumeration type can all be converted into integer type to judge, because shaping has great certainty in equality and inequality, and the decimals represented by float and double have limited precision after all, so it is difficult for computers to judge whether they are equal after exceeding the limit, so they cannot be used.

If else structure can be used

Therefore, switch can only be used for simple jump judgment, and of course it can also be replaced by if else structure.