What is wrong with the short circuit logic in this Java code?

后端 未结 9 1144
挽巷
挽巷 2021-01-18 01:58

Why doesn\'t func3 get executed in the program below? After func1, func2 doesn\'t need to get evaluated but for func3, shouldn\'t it?

if (func1() || func2()          


        
9条回答
  •  终归单人心
    2021-01-18 02:33

    If function 1 always returns true, then Java doesn't need to evaluate the rest of the expression to determine that the whole expression will be true.

提交回复
热议问题