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 Basic Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Basic Question" Watch "Basic Question" New topic

Basic Question

don cline
Ranch Hand

Joined: Oct 10, 2003
Posts: 35
This is a very basic question about syntax, embarrassed to ask, but I forget
the answer, and don't have my references here. I believe this is
a question fitting for this forum.
Consider the following code fragment:

This can be accomplished in a single line, something like:

Can someone help me?

chi Lin
Ranch Hand

Joined: Aug 24, 2001
Posts: 348
use the ? : operator.
[ June 26, 2004: Message edited by: chi Lin ]

not so smart guy still curious to learn new stuff every now and then
Greg T Robertson
Ranch Hand

Joined: Nov 18, 2003
Posts: 91
To be more precise it's
don cline
Ranch Hand

Joined: Oct 10, 2003
Posts: 35
I agree. Here's the link:
subject: Basic Question
It's not a secret anymore!