Results 1 to 4 of 4
Thread: true && !true
- 10-29-2009, 02:18 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 6
- Rep Power
- 0
true && !true
Can someone explain to me what true && !true does?
Here is a sample code:
I know that the nested if is executed since ((c * d) == (a - b)) = TRUE. However, if I change the nested IF to if (true && !true) instead, I don't get why Y and Z is printed. Doesn't it mean TRUE or NOT TRUE and thus X would always be printed?Java Code:int a,b,c,d; a = 10; b = 4; c = 2; d = 3; if ((c + 2 < d) || ((c * d) == (a - b))) if (true || (true && !true)) System.out.print("X"); else { System.out.print("Y"); System.out.print("Z"); }
-
1) what is !true? In other words, what is (not) true?
2) what is anything && the answer to question 1) above
3) regardless of this answer, what is (true || anything)?
-
Nope. You'd better look up what is used for AND and what is used for OR in Java. This is a basic concept that you'll need as you go forward.if (true && !true) instead, I don't get why Y and Z is printed. Doesn't it mean TRUE or NOT TRUE
- 10-29-2009, 02:33 AM #4
Member
- Join Date
- Oct 2009
- Posts
- 6
- Rep Power
- 0
Similar Threads
-
while(true)
By ravian in forum New To JavaReplies: 7Last Post: 06-29-2011, 06:05 AM -
which one of the following is true about interface?
By makpandian in forum New To JavaReplies: 3Last Post: 06-30-2009, 12:23 AM -
A true newbies problem.
By Kaz in forum New To JavaReplies: 3Last Post: 06-25-2009, 06:12 AM -
bug (?) in ProcessBuilder.redirectErrorStream(true);
By gadasie in forum Advanced JavaReplies: 3Last Post: 03-13-2008, 09:04 AM -
setVisible(true) does not work
By Gajesh Tripathi in forum AWT / SwingReplies: 2Last Post: 10-27-2007, 07:32 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks