public class Main { public static void main(String[] args) { int[] A = { 6, 4, 3, 5, 6, 2 }; for (int j = 1; j < A.length; j++) { int key = A[j]; int i = j - 1; while (i >= 0 && A[i] > key) { A[i + 1] = A[i]; i--; } A[i + 1] = key; } } }
public class Main { public static void main(String[] args) { int[] A = { 6, 4, 3, 5, 6, 2 }; for (int j = 1; j < A.length; j++) { int key = A[j]; int i = j - 1; while (i >= 0 && A[i] > key) { A[i + 1] = A[i]; i--; } A[i + 1] = key; } } }