Java when to use the ternary operator such abbreviated format?

When using this ternary operator shorthand format?

When the operator if else, when there is a specific result can be simplified written ternary operator.
Otherwise, if the program in order to output to the console, then do not use if else shorthand. For example:
int = A. 3;
IF (A> 2)
{
System.out.println ( "Yes");
}
the else
{
System.out.println ( "NO");
}

Published 13 original articles · won praise 0 · Views 768

Guess you like

Origin blog.csdn.net/heixue666/article/details/104098405