Advertisement
rjlth

Untitled

Jul 15th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1.  //: operators/TernaryIfElse.java
  2. import static net.mindview.util.Print.*;
  3.  
  4. public class TernaryIfElse {
  5.   static int ternary(int i) {
  6.     return i < 10 ? i * 100 : i * 10;
  7.   }
  8.   static int standardIfElse(int i) {
  9.     if(i < 10)
  10.       return i * 100;
  11.     else
  12.       return i * 10;
  13.   }
  14.   public static void main(String[] args) {
  15.     print(ternary(9));
  16.     print(ternary(10));
  17.     print(standardIfElse(9));
  18.     print(standardIfElse(10));
  19.   }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement