Hello.
Tell me, please, why the sorting method does not work correctly, the figure 5 disappears somewhere. Everything works in the Pascal language (the code translated with maximum accuracy).
class test { protected static int a, b; protected static int[] array = { 2, 21, 42, 43, 567, 5 }; protected static final int ARRAY_LENGTH = array.length; public static void main(String[] args) { for(int i = 0; i < ARRAY_LENGTH - 1; i++) { for(int j = 0; j < ARRAY_LENGTH - 2; j++) { a = array[j]; b = array[j + 1]; if(a > b) { array[j] = b; array[j + 1] = a; } } } for(int i = 0; i < array.length - 1; i++) { System.out.print(array[i] + " "); } } }