Results 1 to 8 of 8
Thread: Tenary condition operator
- 05-04-2011, 05:25 AM #1
Member
- Join Date
- May 2011
- Posts
- 2
- Rep Power
- 0
Tenary condition operator
Question about tenary condition operator. Example is below which used a tenary condition. Not sure why someone would someone use it. Is this used in Java? Also wondering if someone could show me how this would normally be done?
Java Code:circle(g, (nState == 5) ? Color.red : Color.red.darker(), 150, 100); circle(g, (nState == 7) ? Color.orange : Color.orange.darker(), 150, 150);
- 05-04-2011, 05:30 AM #2
Have a look here : Java Ternary Operator
You can use Google as well and find out many more resources related to the same.
Hope that helps,
GoldestJava Is A Funny Language... Really!.gif)
Click on * and add to member reputation, if you find their advices/solutions effective.
- 05-04-2011, 05:31 AM #3
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Im not sure what you mean, a ternary operator is basically a short hand for if else clauses.
- 05-04-2011, 08:05 AM #4
- 05-05-2011, 10:36 AM #5
Not in the way you showed at #4, it can't. The second and third arguments to the ternary are value expressions not statements.Ternary operator can be used in this way.
db
- 05-05-2011, 10:46 AM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,422
- Blog Entries
- 7
- Rep Power
- 17
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 05-05-2011, 11:18 AM #7
This is by far the funniest (out of so many) comments I have seen from you Jos.
I almost fell down from my chair after reading this. :D It was just too much for me to handle!
By the way, this was my previous favorite ;)
GoldestJava Is A Funny Language... Really!.gif)
Click on * and add to member reputation, if you find their advices/solutions effective.
- 05-05-2011, 11:28 AM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,422
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
Waiting on a condition
By nephos in forum New To JavaReplies: 9Last Post: 04-22-2011, 10:05 AM -
string and condition problem
By durdanto in forum New To JavaReplies: 1Last Post: 02-17-2011, 08:20 AM -
basic condition
By ts96 in forum New To JavaReplies: 1Last Post: 02-16-2011, 12:23 PM -
While loop condition
By counterfox in forum New To JavaReplies: 3Last Post: 10-10-2010, 01:14 AM -
IF-Condition in a String
By lenaz in forum Advanced JavaReplies: 1Last Post: 07-18-2009, 12:07 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks