Java Learning--java operator

Source: Internet
Author: User
Tags bitwise operators
Bitwise operators
A = 0011 1100= 0000 1101-----------------A&b = 0000 1100| b = 0011 1101^ b = 0011 0001
A << 2 = 1111 0000
A >>> 2 = 0000 1111 ~a= 1100 0011

Example

 Packageimport_test; Public classEmployee { Public Static voidMain (String args[]) {intA = 60; intb = 13; System.out.println (A|b); System.out.println (A&b); System.out.println (A^b); System.out.println (~a); System.out.println (A<< 2); System.out.println (A>>> 2); }}

Results

611249-6124015
Conditional operators
 Public class Employee {    publicstaticvoid  main (String args[]) {        int a = ten;         int b = 8;         = a > B? "A > B": "A<= B";        System.out.println (rev);    }}

Results

A > B
instanceof operator
 Public classEmployee { Public Static voidMain (String args[]) {Employee eg=NewEmployee (); String s= "String"; System.out.println (SinstanceofString); SYSTEM.OUT.PRINTLN (eginstanceofEmployee); //Boolean B = s instanceof Employee); //System.out.println (b);    }}

Results

true true

Java Learning--java operator

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.