Four logical operators of Java

Source: Internet
Author: User

Of the logical operators in Java, there are four classes && (short circuit and), & (with), | | (short-circuit or), | (non-shorted or)

&& and & both indicate that with,&&, when the first condition is false, subsequent conditions do not execute,& to judge all conditions

|| and | Both Express or, | | Indicates that the first condition is true, and the following conditions are not judged; | To judge all the conditions

1        if((23>24) && (100/0==0)) {//23>24 is false, the following conditions do not perform the judgment, when 23<24 is true, the following conditions continue to execute the judgment, throwing an exception java.lang.ArithmeticException:/by Zero2         }3         if((23>24) & (100/0==0)) {//the condition must be judged, throw exception java.lang.ArithmeticException:/by Zero4         }5         if((23<24) | | (100/0==0)) {// || Short circuit or, when the first condition is true, the latter condition does not perform judgment;6         }7         if((23>24) | (100/0==0)) {//| non-shorted or, all conditions must be judged8}

Four logical operators of Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.