A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Arduino in Action
this week in the
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
PLease ignore previous post -Ternary operator
Joined: Aug 20, 2008
Aug 20, 2008 22:53:00
What is wrong with this code:
The complilation error being "Not a statement"
I also tried
though it didnt look right..
Can you please give me an explanation?
Joined: Mar 22, 2005
Aug 20, 2008 23:35:00
The "a ? b : c" construct is an expression, not a statement, and can't be used where a statement is expected. Try
System.out.println( i%2==0 ? "Even" : "Odd" );
Java web charts
Jesper de Jong
Joined: Aug 16, 2005
Aug 21, 2008 01:37:00
Note: You can edit your own posts by clicking the
icon on the post - no need to start a completely new post if you made some mistake.
Java Beginners FAQ
JavaRanch SCJP FAQ
The Java Tutorial
Java SE 7 API documentation
- My blog about Scala
Joined: Oct 13, 2005
Aug 21, 2008 04:53:00
Note: more details in
don't like two threads about the same question
, I feel obliged to close one. I shall close this thread; please everybody continue any discussion on the other thread quoted above.
I agree. Here's the link:
- it saves me about five hours per week
subject: PLease ignore previous post -Ternary operator
Listing even and odd numbers
"assert i%2==0 : i--;"question required
Syntax error for ternary operator
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013