Solved

using if in a program like the following example.

Posted on 2004-09-03
2
195 Views
Last Modified: 2010-03-31
System.out.println("\nThere were " + iArgumentCount + " command line " +
((iArgumentCount != 1)? "arguments":"argument") + ".");

This line in an program we are trying to disect (for school). Uses a ? and what looks like an if statement. Can you help explain this to me?

Thank You.

Steve
0
Comment
Question by:spoindex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 92

Expert Comment

by:objects
ID: 11978299
Its a ternary statement.

Same as:

String args = null;
if (iArgumentCount != 1)
{
   args = "arguments";
}
else
{
   args = "argument";
}
System.out.println("\nThere were " + iArgumentCount + " command line " + args + ".");
0
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 11978302
a = b ? c : d; is shorthand for if ( b ) a = c; else a = d;
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to configure empty element in XML Document parser? 15 59
Selenium docs api java index 3 98
JDBC performance 8 35
Overriding a method 3 14
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question