Computer Science Canada

Really Easy Problem

Author:  spiderman [ Tue Apr 24, 2007 7:36 pm ]
Post subject:  Really Easy Problem

SOMEONE QUICKLY TELL ME WHAT THE BUTTON IN JAVA IS FOR THE WORD "or"
FOR AND ITS "&" but i cant remember for or
SOmeone answer quickly!!!!

Author:  Dan [ Tue Apr 24, 2007 7:49 pm ]
Post subject:  RE:Really Easy Problem

No need for all caps.

Also it is not relay a button or signal char but 2 of them. 1st AND is not just "&" but "&&" and OR is "||".

I am a bit worried that the reason for needing this so quickly is that you are writing a test. However i will assume the best for now.


You may wont to check out some of the tutorials we have on java like:

http://www.compsci.ca/v3/viewtopic.php?t=9576

Author:  spiderman [ Tue Apr 24, 2007 8:28 pm ]
Post subject:  Re: Really Easy Problem

Im writig a program actually but I have to hand it in before 12 o clock or I fail thats why Im in a rush!

Author:  richcash [ Tue Apr 24, 2007 10:28 pm ]
Post subject:  Re: Really Easy Problem

I just wanted to add that there is also & and | operators in Java.
&& and || are short-circuit while & and | are not.

x && y
    
<- if x is false, then y is not executed (because there is no need to, the result of the && will be false)
x || y
    
<- if x is true, then y is not executed

This means that doing this is safe :
Java:
if x != 0 && y/x == 1

while this will cause an error if x is 0 :
Java:
if x != 0 & y/x == 1


: