Bitwise AND Operations in Java

Source: Internet
Author: User

1  Packagescanner;2 3  Public classSingleand {4     5      Public Static voidMain (string[] args) {6         7         int[] First = {10,15,8,5,0};8         9         int[] Second = {4,8,1,2};Ten          One         intresult = 0; A          -          for(inti=0; i<first.length; i++){ -              the              for(intj=0; j<second.length; J + +){ -                  -result = First[i] &Second[j]; -                  +System.out.println ("========================================"); -                  + System.out.println (integer.tobinarystring (first[i)); A                  at System.out.println (integer.tobinarystring (second[j)); -                  - System.out.println (integer.tobinarystring (Result)); -                  -System.out.println (First[i] + "&" + second[j] + "=" +result); -                  in                  -             } to         } +     } -}

Result of Operation:

========================================
1010
100
0
10&4=0
========================================
1010
1000
1000
10&8=8
========================================
1010
1
0
10&1=0
========================================
1010
10
10
10&2=2
========================================
1111
100
100
15&4=4
========================================
1111
1000
1000
15&8=8
========================================
1111
1
1
15&1=1
========================================
1111
10
10
15&2=2
========================================
1000
100
0
8&4=0
========================================
1000
1000
1000
8&8=8
========================================
1000
1
0
8&1=0
========================================
1000
10
0
8&2=0
========================================
101
100
100
5&4=4
========================================
101
1000
0
5&8=0
========================================
101
1
1
5&1=1
========================================
101
10
0
5&2=0
========================================
0
100
0
0&4=0
========================================
0
1000
0
0&8=0
========================================
0
1
0
0&1=0
========================================
0
10
0
0&2=0

Bitwise AND Operations in Java

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.