How does Java deal with multiple conditions inside a single IF statement

前端 未结 4 1853
谎友^
谎友^ 2020-12-15 21:40

Lets say I have this:

if(bool1 && bool2 && bool3) {
...
}

Now. Is Java smart enough to skip checking bool2 and bool2 if boo

4条回答
  •  余生分开走
    2020-12-15 22:36

    Yes,that is called short-circuiting.

    Please take a look at this wikipedia page on short-circuiting

提交回复
热议问题