java - Compere if statement short form -


ı want use short form if statement. how can ı write if statement @ one line? , how can ı compare them ı know there same question @ here. statement not have else ı not without else statement.

public int compareto(uyum u) {             if (uyum < u.uyum)                 return -1;             if (uyum > u.uyum)                 return 1;             return 0;         } 

you can use ternary operator :

 return uyum < u.uyum ? -1        : uyum > u.uyum ? 1        : 0; 

Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -