package org.kodejava.lang;
public class OrDemo {
public static void main(String[] args) {
int numberA = 16;
int numberB = 4;
// Operator "|" is used for doing bitwise OR 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 | 4 = 20
10000 | 100 = 10100
Latest posts by Wayan (see all)
- How do I create a table with multiple header in iText 8? - March 16, 2024
- How do I add Image to a Table in iText 8? - March 11, 2024
- How do I downgrade Android SDK emulator version? - February 12, 2024