File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Advantage of Ternary operator ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Advantage of Ternary operator ?" Watch "Advantage of Ternary operator ?" New topic
Author

Advantage of Ternary operator ?

Saibabaa Pragada
Ranch Hand

Joined: Oct 24, 2010
Posts: 162
Hi, When should we go for Ternary operator when compared to if-else if-else loop?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

If-else isn't a "loop".

I use the ternary operator whne choosing between two values, and if-else when choosing between operations.

For example:


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Advantage of Ternary operator ?
 
Similar Threads
operator confusion
can any one explain this
conditional operators and jQuery
Alternative to if else block
A curious problem on Short Circuit & and ternary operator.