I ran in the morning, I will ask the teacher to find the root of the problem.
In fact, it is not very profound, mainly, I have written an algorithm to write an algorithm.
However, the difference is very serious, and it is very serious.
Int Arr [] = {95, 23, 45, 66, 79, 84, 100, 54, 87, 67, 94, 81, 83, 76, 84, 66, 88, 91, 25, 77, 84, 22, 56, 78, 49, 83, 89, 86, 84, 44};
For (int i = 0; I The above is a problem An error sentence is for (int J = 0; j Arr.Length = 30 Because the number of Java's array is from 0 - N-1, the array subscript is the largest. When i = 0, J = 0 J can be equal to 29 j So when IF (Arr [J] Because Arr [J 1] = Arr [30] It is good to find the key to finding the problem. Change for for (int J = 0; j In the process of this debug, I learned from the teacher from the teacher. Above the sentence of IF (Arr [J] The implementation of the entire cycle can be observed. At this time, the error message is as follows: i = 0 j = 0i = 0 j = 1i = 0 J = 2i = 0 j = 3i = 0 j = 4i = 0 j = 5i = 0 j = 6i = 0 j = 7i = 0 j = 8i = 0 j = 9i = 0 j = 10i = 0 j = 11i = 0 j = 12i = 0 j = 13i = 0 j = 14i = 0 j = 15i = 0 j = 16i = 0 j = 0 J = 0 j = 18i = 0 j = 19i = 0 j = 20i = 0 j = 0 j = 23i = 0 j = 24i = 0 j = 25i = 0 j = 26i = 0 j = 27i = 0 j = 28i = 0 j = 29Exception in Thread "Main" java.lang.ArrayIndexOutofboundsexception: 30 at sort.main (Sort.java: 13) So it can be very intuitive to see that the outer loop has not been implemented once. In the inner layer, it is wrong when it is executed to J = 29. You can find mistakes near this statement at this time. Quite convenient After all, it's a good harvest in Java.