Java Algorithms-Symbols &

Source: Internet
Author: User

& and Operators

And the operator is denoted by the symbol "&", which uses the following rules:
Two operands have a bit of 1 and the result is 1, otherwise the result is 0

For example, the following program segment.

 Public class data13{publicstaticvoid  main (string[] args) {int a=129 ; int b=128; System.out.println ("A and B" with the result is: "+ (a&b));}}

Run results
A and B with the result is: 128
The following analysis of this program:

The value of "a" is 129, converted to binary is 10000001, and the value of "B" is 128, converted to binary is 10000000. According to the operator's operation Law, only two bits are 1, the result is 1, you can know the result is 10000000, that is, 128.

Java Algorithms-Symbols &

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.