Two conditions in one if statement does the second matter if the first is false?

前端 未结 6 1179
日久生厌
日久生厌 2020-12-04 23:52

Okay, so I have this piece of code tested and I found there isn\'t any exception thrown out.

public static void main(String[] args) {
    int[] list = {1,2}         


        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-05 00:30

    Yes. If the first condition is not satisfied then the remainder are not evaluated. This is known as short-circuiting. See here for more details. Note that this isn't particular to Java and lot of other languages will do the same.

提交回复
热议问题