Java interview (1)--Java logical operators

Source: Internet
Author: User
Tags logical operators

1 classdemo04{2      Public Static voidMain (string[] args) {3         //logical Operators4         5         //Example 16System.out.println (true|false&false);7         //result True8         //The priority of,& in the Java language is higher than |9         Ten          One         //Example 2 A         //three-mesh operator: relationship expression? value 1: Value 2; -         intA = 10; -         intb = 5; the         intc = (a>b)? (a=4):(b=5); - System.out.println (a); - System.out.println (b); - System.out.println (c); +         //results: 4,5,4 -          +          A         //Example 3 at         intA = 10; -         Doubleb = 9.5; -System.out.println (a>b?a:b); -         //Results: 10.0 -          -          in         //Example 4 -System.out.println (3>2?1:true); to         //Results: 1 +         /* - This is actually an automatic packing. the 1 has been installed as an integer type * true is loaded as a Boolean type $ Object obj = 3>2?1:true;Panax Notoginseng System.out.println (obj); -         */ the          +          A         //Example 5 the          Shorts = 1; +s = s + 1;//Error: 1 is of type int, s+1 is int type, then assigned to short type -s + = 1;//correct: The result of the + = operator is the same as the left type after the calculation is completed $          $          -          -         //Example 6 the         intA = 1; -A + = 3.5;Wuyi System.out.println (a); the         //Results: 4 -     } Wu}

Java interview (1)--Java 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.