How to use greater than or equal in a switch statement

后端 未结 8 2456
忘掉有多难
忘掉有多难 2021-02-19 04:10

What is the best way to check if variable is bigger than some number using switch statement? Or you reccomend to use if-else? I found such an example:

int i;

i         


        
8条回答
  •  闹比i
    闹比i (楼主)
    2021-02-19 04:52

    Unfortunately you cannot do that in java. It's possible in CoffeeScript or other languages.

    I would recommend to use an if-else-statement by moving your "do stuff" in extra methods. In that way you can keep your if-else in a clearly readable code.

提交回复
热议问题