Java boolean |= or &= or ^= notation

Source: Internet
Author: User

Package jack.test; /** * Sometimes look at the open source framework can learn a lot of useful things, see the simple log when you find a writing * in the Boolean operation can be used |= or &= or ^= operations. * Logical operator * The Operation object and result of the logical operator are all Boolean type, total six: *. (logical non) && (logic and) | | (logical OR) * ^ (Logical AND/) & (Logic and) | (Logical OR) * Bitwise AND ' & ' can also be used as logic and use, but not optimized, while ' && ' operators are optimized. To ' | ' Operators are similar. * @author Administrator * * */public class Test {public static void main (string[] args) {Boolean isTrue = false; IsTrue | = true; System.out.println (isTrue); IsTrue = false; IsTrue |= false; System.out.println (isTrue); IsTrue = true; IsTrue |= true; System.out.println (isTrue); IsTrue = true; IsTrue |= false; System.out.println (isTrue); IsTrue &= false; System.out.println (isTrue); IsTrue = true; IsTrue ^= isTrue; System.out.println (isTrue); } }

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.