This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes A simple question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "A simple question" Watch "A simple question" New topic

A simple question

danesh far

Joined: Nov 25, 2004
Posts: 15
Hi,could you please let me know what the following ststement says:

theDX = theDX > MAX_V ? MAX_V : theDX;
[ December 09, 2004: Message edited by: Ernest Friedman-Hill ]
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24189

I edited your post to remove some superfluous formatting.

The ? and : characters together are the "ternary operator." It's basically a shorthand way of writing "if/then". Another way to write exactly the same thing would be

Of course, written out like this, the "else" part is redundant.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: A simple question
It's not a secret anymore!