Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to perform an XOR on a set of Booleans
To perform XOR on a set of Booleans, firstly let us consider the following Boolean array.
boolean[] arr = { true, true, false };
Let us now create a nested loop and within that perform XOR operation.
for (boolean one : arr) {
for (boolean two: arr) {
// XOR
boolean res = one ^ two;
}
}
Here is the entire example to displayXOR on a set of Booleans.
Example
public class Demo {
public static void main(String[] args) {
// boolean array
boolean[] arr = { true, true, false };
for (boolean one : arr) {
for (boolean two: arr) {
// XOR
boolean res = one ^ two;
System.out.println(res);
}
}
}
}
Output
false false true false false true true true false
Advertisements