wood burning stoves 2.0*
The moose likes Mock Exam Errata and the fly likes Jwhiz,  Logical OR on int. What? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "Jwhiz,  Logical OR on int. What? " Watch "Jwhiz,  Logical OR on int. What? " New topic
Author

Jwhiz, Logical OR on int. What?

Mike Kelly
Ranch Hand

Joined: Jul 18, 2001
Posts: 78
Jwhiz exam#6 quest10 says this code compiles correctly, but I thought logical OR could not be done on int types, only booleans?
Any help?
(please excuse the OR operator)
int i = 1;
int j = 2;
if(i == 1 ll j == 2)
{
System.out.println("Ok");
}
Mariusz Szurnacki
Ranch Hand

Joined: Sep 12, 2001
Posts: 44
Look:
1. comparison operators � all return boolean type
2. comparison operators have higher priority than logical OR
So, in this case, you "have" the following statement:
if((i == 1) ll (j == 2))
Have a nice day,
Mariusz

<BR>
Mike Kelly
Ranch Hand

Joined: Jul 18, 2001
Posts: 78
Ahh yes, Thank-you Mariusz. Precedence of operators and operations, I have it right here in my notes. I've got the concept now, thanks.
 
 
subject: Jwhiz, Logical OR on int. What?