r/javahelp • • Mar 13 '20

Solved What do ~ and ^ mean in Java?

I can't find it on the internet, what does it mean?

Edit: thanks everyone!

25 Upvotes

8 comments sorted by

26

u/[deleted] Mar 13 '20

~ is bitwise complement/negation and ^ is bitwise XOR.

0

u/[deleted] Mar 13 '20

[deleted]

12

u/[deleted] Mar 13 '20

That's not true in Java. There is no exponent operator in Java. You have to use an exponent method like Math.pow. OP asked about what the operators do in Java specifically.

11

u/desrtfx Out of Coffee error - System halted Mar 13 '20

Removed as wrong and misleading.

2

u/ryado Mar 13 '20

Not in java

19

u/desrtfx Out of Coffee error - System halted Mar 13 '20

I can't find it on the internet,

Always go to the source:

https://docs.oracle.com/javase/tutorial/java/nutsandbolts/opsummary.html

1

u/[deleted] Mar 24 '20

They're bitwise operations, I'm sure something will come up if you Google Java bitwise operators

1

u/drdonv Mar 24 '20

Yeah lol I didn't know it was bitwise (didn't even know what it was at the time), so my search was "what is ~ in Java and nothing showed up." Thanks!

1

u/[deleted] Mar 24 '20

No prob 👍🏻