This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes system.out.print with ternary operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "system.out.print with ternary operator" Watch "system.out.print with ternary operator" New topic

system.out.print with ternary operator

senthil doraiswamy

Joined: Feb 14, 2002
Posts: 9
I would like to know why second argument in System.out.print ( args[i] ) is not printed when i = 0.

class Test {
public static void main(String[] args) {
for (int i = 0; i < args.length; i++)
System.out.print(i == 0 ? args[i] : " " + args[i]);

--- sen.
Ashish Hareet
Ranch Hand

Joined: Jul 14, 2001
Posts: 375
Read i == 0 ? args[i] : " " + args[i] as follows

More on the terenary operator -
[ June 19, 2008: Message edited by: Ashish Hareet ]
senthil doraiswamy

Joined: Feb 14, 2002
Posts: 9
Ashish, thank you.
I agree. Here's the link:
subject: system.out.print with ternary operator
Similar Threads
System.out.println(0xffff); //ans???
Doubt in the output of this program.
Unreachable statement
Multiplication Table
Why is this printing 1,0 instead of 1,1