In the Java programming language, a ‘variable’ is used to store a value. Different kinds of operations can be performed on the variables by means of ‘operators’. The Java programming language has a number of operators and these are listed below:
- Arithmetic operators(+,-,*, /,++,–,%)
- Relational operators(<,<=,>,>=,==,!=)
- Logical operators(&,|,&&,||,^)
- Conditional operators(?:)
- instanceof operator
- assignment operator(=,+=,-=)
The arithmetic operator deals with the mathematical operations of addition, subtraction, multiplication, division and modulus. The relational operators deals with comparison of the operands(or the variables used) The conditional operator is a ternary operator. The logical operators work only with boolean expressions(like true and false)
XOR operator: (^)
The XOR operator is represented with a ‘^‘. If the two operands are same, then the result is a ‘0’ or false and if the two operands are different then the result is a ‘1’ or true. For example,
|Operand 1||Operand 2||Result|
XOR operator works with both boolean values and numerical values. The numerical values will be converted to binary values and the XOR operation will be done.
This is the working of the XOR operator. This post is for alphabet ‘X’ for the BlogchatterA2Z challenge… the previous post is here...
Jayanthi Manikandan has an undergraduate degree in Computer Science from India and a Master’s degree in Information systems with a specialization in Information security from Detroit, MI, USA.
She has been passionate about Information security and has several years of experience writing on various technical topics. Additionally, she loves to pen a few personal thoughts here as well! 🙂