Solving problems. Logical operators. &,!, |, ^

Source: Internet
Author: User

1  PackageCom.java7;2 //demonstrate the relational and logical operators.3  Public classRellogops {4      Public Static voidMain (string[] args) {5         intI, J;6         BooleanB1, B2;7         8i = 10;9j = 11;Ten          One         if(I < J) System.out.println ("I < J"); A         if(I <= J) System.out.println ("I <= J"); -         if(I! = j) SYSTEM.OUT.PRINTLN ("I! = j"); -         if(i = = j) System.out.println ("i = = j");//This won ' t execute the         if(I >= J) System.out.println ("I >= J");//This won ' t execute -         if(i > J) System.out.println ("I > J");//This won ' t execute -          -B1 =true; +B2 =false; -         if(B1 & B2) System.out.println ("B1 & B2 is true");//false +         if(! (B1 & B2)) SYSTEM.OUT.PRINTLN ("!" ( B1 & B2) is true ");//true:!true = false;!false = True (reverse; As long as there is a true) A         if(B1 | b2) System.out.println ("B1 | B2 is true ");//True:true or False returns True (as long as there is a true) at         if(B1 ^ b2) System.out.println ("B1 ^ B2 is true");//True:true xor False Returns True (with and only one true) -          - System.out.println (); -          -B1 =false; -B2 =true; in         if(B1 & B2) System.out.println ("B1 & B2 is true");//false -         if(! (B1 & B2)) SYSTEM.OUT.PRINTLN ("!" ( B1 & B2) is true ");//true:!false = true;!true = False (reverse; As long as there is a true) to         if(B1 | b2) System.out.println ("B1 | B2 is true ");//True:false or True returns Ture (as long as there is a true) +         if(B1 ^ b2) System.out.println ("B1 ^ B2 is true");//True:false xor True returns True (with and only one true) -          the System.out.println (); *          $B1 =true;Panax NotoginsengB2 =true; -         if(B1 & B2) System.out.println ("B1 & B2 is true");//true the         if(! (B1 & B2)) SYSTEM.OUT.PRINTLN ("!" ( B1 & B2) is true ");//false:!true = false;!true = False (reverse; As long as there is a true) +         if(B1 | b2) System.out.println ("B1 | B2 is true ");//True:true or True returns True (as long as there is a true) A         if(B1 ^ b2) System.out.println ("B1 ^ B2 is true");//False:true xor True returns False (with and only one true) the          + System.out.println (); -          $B1 =false; $B2 =false; -         if(B1 & B2) System.out.println ("B1 & B2 is true");//false -         if(! (B1 & B2)) SYSTEM.OUT.PRINTLN ("!" ( B1 & B2) is true ");//true:!false = true;!false = True (reverse; As long as there is a true) the         if(B1 | b2) System.out.println ("B1 | B2 is true ");//False:false or False returns False (as long as there is a true) -         if(B1 ^ b2) System.out.println ("B1 ^ B2 is true");//False:false xor False returns False (with and only one true)Wuyi     } the}

Solving problems. Logical operators. &,!, |, ^

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.