java - use of ternary operator <p>I got quite a large code with 4 different conditions which I tried to shorten using the conditional ternary operator as <a href="http://alvinalexander.com/java/edu/pj/pj010018" rel="nofollow">descibed here</a>. However, I can't manage the right syntax since I have more than 2 conditions. Could someone explain how to use the ternary operator in such case? My code goes below</p> <p>And no, I'm not asking to write code for me, I'm looking for an explanation of ternary operator use with multiple conditions</p> <pre><code> if (mp.getCurrentPosition() / 1000 / 60 &lt; 10 &amp;&amp; mp.getCurrentPosition() / 1000 % 60 &lt; 10) { tvTimeElapsed.setText("0" + Integer.toString(mp.getCurrentPosition() / 1000 / 60) + ":" + "0" + Integer.toString(mp.getCurrentPosition() / 1000 % 60)); } else if (mp.getCurrentPosition() / 1000 / 60 &lt; 10 &amp;&amp; mp.getCurrentPosition() / 1000 % 60 &gt;= 10) { tvTimeElapsed.setText("0" + Integer.toString(mp.getCurrentPosition() / 1000 / 60) + ":" + Integer.toString(mp.getCurrentPosition() / 1000 % 60)); } else if (mp.getCurrentPosition() / 1000 / 60 &gt;= 10 &amp;&amp; mp.getCurrentPosition() / 1000 % 60 &lt; 10) { tvTimeElapsed .setText(Integer.toString(mp.getCurrentPosition() / 1000 / 60) + ":" + "0" + Integer.toString(mp.getCurrentPosition() / 1000 % 60)); } else { tvTimeElapsed .setText(Integer.toString(mp.getCurrentPosition() / 1000 / 60) + ":" + Integer.toString(mp.getCurrentPosition() / 1000 % 60)); } </code></pre>