Solved

using if in a program like the following example.

Posted on 2004-09-03
2
194 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maven module vs maven project 3 73
going to wrong jsp page 2 47
restrict decimal places for double datatype 10 31
program arguments vs VM arguments 4 28
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

756 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