• Post Reply Bookmark Topic Watch Topic
  • New Topic

Conditional Operator  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the equivalent of the code below.


Is it


or


I believe it is the second option but a book I'm following says it is the first option. Please help !!
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice line of thought. Unfortunately, Java don't speak that language. If else is a conditional operator that states statements can only be carried out if the condition is true or false otherwise.
 
Saloon Keeper
Posts: 3330
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The second.

Same as:
System.out.println( (x>10) ? ">" : ( (x<10) ? "<" : "=" ) );
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!