0 votes

What is ^ operator called what does it do? if anybody can help?

Jun 22, 2018 in Java 689 views

## 3 answers to this question.

0 votes

^ operator is called bitwise XOR operator.

Binary XOR Operator copies the bit if it is set in one operand but not both.

For example:

a = 0011 1100

b = 0000 1101

(A ^ B) will give 49 which is 0011 0001

answered Jun 26, 2018 by
• 1,290 points
0 votes

## The ^ operator in Java

^ in Java is the exclusive-or ("xor") operator.

Let's take 5^6 as example:

```(decimal)    (binary)
5     =  101
6     =  110
------------------ xor
3     =  011```

This the truth table for bitwise (JLS 15.22.1) and logical (JLS 15.22.2) xor:

```^ | 0 1      ^ | F T
--+-----     --+-----
0 | 0 1      F | F T
1 | 1 0      T | T F```

More simply, you can also think of xor as "this or that, but not both!".

answered Oct 31, 2018 by
• 6,910 points
0 votes

## It's bitwise XOR, Java does not have an exponentiation operator, you would have to use Math.pow() instead.

answered Oct 31, 2018 by
• 6,910 points

0 votes
1 answer

## What is the 'instanceof' operator used for in Java?

It's an operator that returns true if ...READ MORE

0 votes
1 answer

## What is ?: this operator called in java ? how dose it function?

? :  is the Conditional operator and is ...READ MORE

+1 vote
3 answers

## What is the syntax to declare and initialize an array in java?

You can use this method: String[] strs = ...READ MORE

0 votes
2 answers

## What is the use of toString method in Java and how can I use it ?

Whenever you require to explore the constructor ...READ MORE

+5 votes
4 answers

## How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

+1 vote
1 answer

## How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

0 votes
1 answer

## What are the differences between getText() and getAttribute() functions in Selenium WebDriver?

See, both are used to retrieve something ...READ MORE

0 votes
1 answer

## Selenium JARS(Java) missing from downloadable link

Nothing to worry about here. In the ...READ MORE

0 votes
1 answer

## What is the use of assert keyword in java?

Java assertion feature allows the developer to ...READ MORE

0 votes
2 answers

## What is the easiest way to iterate through the characters of a string in Java?

There are two approaches to this: for(int i ...READ MORE