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