|
Thread: Or?
-
May 1st, 2003, 05:56 AM
#1
Thread Starter
Lively Member
Or?
if ((vtype != 1) || (vtype != 2) || (vtype != 3))
System.out.println("Invalid input\n");
i input 3, and it prints out the message... what gives?
-
May 1st, 2003, 06:33 AM
#2
or course it prints out the message!!
3 <> 1, so the first part will let it through! (whatever value you put in, it will ALWAYS show the message)
ie:
if ((vtype != 1) || (vtype != 2) || (vtype != 3))
which becomes: if (TRUE) or (TRUE) or (FALSE)
which becomes: if (TRUE)
try use AND instead
-
May 2nd, 2003, 12:45 AM
#3
Dazed Member
-
May 2nd, 2003, 03:46 AM
#4
Originally posted by Dilenger4
Right?? or am i staying up too late.  [/B]
absolutely right - and a better explanation than mine too
-
May 2nd, 2003, 12:16 PM
#5
Dazed Member
Conditional operators give me a headache.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|