Java - Sort three numbers

Description

Sort three numbers

Demo

public class SortThree {

  public static void main(String args[]) {
    int a = 231;/*www  .  ja  v a 2 s.c o  m*/
    int b = 177;
    int c = 45;

    int temp;

    if (b < a) {
      temp = a;
      a = b;
      b = temp;
    }

    if (c < b) {
      temp = b;
      b = c;
      c = temp;
    }

    if (b < a) {
      temp = a;
      a = b;
      b = temp;
    }

    System.out.println(a);
    System.out.println(b);
    System.out.println(c);
  }
}

Related Topic