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

前端 未结 6 1186
日久生厌
日久生厌 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:25

    Right from the javadoc:

    The Conditional Operators

    The && and || operators perform Conditional-AND and Conditional-OR operations on two boolean expressions. These operators exhibit "short-circuiting" behavior, which means that the second operand is evaluated only if needed.

    && Conditional-AND || Conditional-OR

提交回复
热议问题