Common Object · Arrays and class Integer class
An array of advanced bubble sort illustrating the principles of
* A: Paint Demo
* requirements:
the array elements: {24, 69, 80, 57, 13}
please sort the array elements
* Bubble sort:
adjacent elements pairwise comparison, the larger the next release, for the first time is completed, the maximum in the biggest index
An array of advanced bubble sort code implementation
* A: Case presentation
* array of advanced bubble sort codes
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
Package com.heima.array; public class Demo1_Array { public static void main (String [] args) { int [] = {ARR 24, 69, 80, 57 is, 13 is }; bubbleSort (ARR); for ( int I = 0 ; I <arr.length; I ++ ) { of System.out.print (ARR [I] + "" ); } } / * * bubble sort: * 1, return type, void * 2, parameter list, int [ ] ARR * / public static void bubbleSort ( int [] ARR) { for ( int0 = I; I <arr.length -. 1; I ++) { // outer loop: arr.lenth-1 need only compare times on the list for ( int J = 0; J <arr.length - I -. 1; J ++) { // Save preventing a overindexing, -i and efficiency IF (ARR [J]> ARR [J +. 1 ]) { int tmp = ARR [J]; ARR [J] = ARR [J +. 1 ]; ARR [J +. 1] = tmp; } } } } }
Sort illustrating the principles of an array of advanced selection
* A: Paint Demo
* requirements:
* array elements: {24, 68, 80, 57, 13}
* Please sort the array elements
* Selection Sort
* index starts from 0, and the following sequence comparison elements, small put forward, the first time is completed, the minimum in the minimum index