Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

system.out.print with ternary operator

 
senthil doraiswamy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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]);
System.out.println();
}
 
Ashish Hareet
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read i == 0 ? args[i] : " " + args[i] as follows

More on the terenary operator - http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.25
[ June 19, 2008: Message edited by: Ashish Hareet ]
 
senthil doraiswamy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ashish, thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic