Java Programming: & vs &&

Status
You're currently viewing only Ruziel's posts. Click here to go back to viewing the entire thread.
Not open for further replies.

Ruziel

Ars Praetorian
573
Subscriptor++
Umm.. that's not right... in Java (and C/C++ if I remember correctly) the single "|" and "&" are bit-wise operators, not logical operators, they are used for completely different things.

You use the "&&" and "||" for boolean statements:

true && true = true
true && falase = false
false && false = false

true || true = true
true || false = true
false || false = false

You use the "&" and "|" for bit operations, given the following are binary numbers:

1010 & 0101 = 0000
1010 & 1000 = 1000

1010 | 0101 = 1111
1010 | 0000 = 1111
 
Status
You're currently viewing only Ruziel's posts. Click here to go back to viewing the entire thread.
Not open for further replies.