Ad

Just another way... A ternary way.

Code
Diff
  • public class BiggerNum{
    
      /**
       * @param a integer of param1
       * @param b integer of param2
       * @return the bigger integer of a and b
       * If a equals b, return either one
       */
      public static int compare(int a, int b) {
        return a > b ? a : a < b ? b : a;
      }
    }
    • public class BiggerNum{
    • /**
    • * @param a integer of param1
    • * @param b integer of param2
    • * @return the bigger integer of a and b
    • * If a equals b, return either one
    • */
    • public static int compare(int a, int b) {
    • return Math.max(a,b);
    • return a > b ? a : a < b ? b : a;
    • }
    • }