This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jwhiz, Logical OR on int. What?
 
Similar Threads
TicTacToe Game..
shift
Inner Loop
Euler31
Urgent: Help Required With Nested For Loops