Java program to sort array using temporary variable

Program

import java.util.Scanner;
public class SortArrayUsingTempVariable {
  private void sortUsingTemp(int array[]) {
    for (int i = 0; i < array.length; i++) {
      for (int j = i + 1; j < array.length; j++) {
        int temp = 0;
        if (array[i] > array[j]) {
          temp = array[i];
          array[i] = array[j];
          array[j] = temp;
        }
      }      
      System.out.println(array[i]);    
    }
  }
  public static void main(String[] args) {
    int i = 0;
    System.out.println("Enter the required size of the array: ");
    Scanner reader = new Scanner(System.in);
    int size = reader.nextInt();
    int inputArray[] = new int[size];
    System.out.println("Enter the elements of the array: ");
    for (i = 0; i < size; i++) {
      inputArray[i] = reader.nextInt();
    }
    SortArrayUsingTempVariable sortArrayUsingTempVariable = new SortArrayUsingTempVariable();
    System.out.println("Array elements sorted in ascending order: ");
    sortArrayUsingTempVariable.sortUsingTemp(inputArray);
  }
}

Output

javac .\SortArrayUsingTempVariable.java
java SortArrayUsingTempVariable        
Enter the required size of the array: 
5 
Enter the elements of the array: 
100
54
76
12
4
Array elements sorted in ascending order: 
4
12
54
76
100