package org.kodejava.lang;
public class AndDemo {
public static void main(String[] args) {
int numberA = 16;
int numberB = 16;
// Operator "&" is used for doing bitwise AND operation
int result = numberA & numberB;
System.out.println(numberA + " & " + numberB + " = " + result);
// Print the result in binary format
System.out.println(Integer.toBinaryString(numberA) +
" & " + Integer.toBinaryString(numberB) +
" = " + Integer.toBinaryString(result));
}
}
The result of the code snippet:
16 & 16 = 16
10000 & 10000 = 10000
Latest posts by Wayan (see all)
- How do I split large excel file into multiple smaller files? - April 15, 2023
- How do I get the number of processors available to the JVM? - March 29, 2023
- How do I show Spring transaction in log / console? - March 29, 2023