Logical OR operator

Hi, Anyone can help how to solve the following ..System.out.println( 4 | 7);I have tried with logical opertor (0100 OR 0111) with result 11 !!but the answer was7 ?.-Alex
[212 byte] By [gw@balaa] at [2007-10-1 0:41:33]
# 1
0100 | 0111 = 0111 = 7
CeciNEstPasUnProgrammeura at 2007-7-8 0:56:00 > top of Java-index,Security,Event Handling...
# 2

It is not logical but numerical operator in this case. Indeed,

System.out.println( 4 || 7);

does not even compile.

Gooc old C does not have a logical (boolean) type, it uses integers on the syntax level too. C++ has the "bool" type, but it maintains the logical <-> integer conversion.

In java the logical type is separated from the integral ones; there is no boolean -> integer conversion.

For convenience however single & and | can be applied to booleans.

BIJ001a at 2007-7-8 0:56:00 > top of Java-index,Security,Event Handling...
# 3
> For convenience however single & and | can be applied> to booleans.It's not just convenience.(a.makeTrue() && b.makeTrue()) is not the same as(a.makeTrue() & b.makeTrue())
CeciNEstPasUnProgrammeura at 2007-7-8 0:56:00 > top of Java-index,Security,Event Handling...