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

前端 未结 6 1188
日久生厌
日久生厌 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-05 00:23

    You have specified in your IF statement that both of the conditions should be true for the System.out.println to be executed. So if the first condition itself fails,the second condition is not checked (this is for AND operator). But the second condition will be cheked if you have specified OR operator in the If statement.

提交回复
热议问题