http://www.verejava.com/?id=16992682424030
/* Using the bubbling algorithm: arrays the score from small to large sort output idea: The first order of 1. Compares the n elements of an array from the first element to the following elements 2. If the previous data is larger than the data behind it, the two switching positions until the loop is complete, that The largest data in the array will be in the last position of the array. The first order of 3. And so on, the remaining unsorted n-i elements are again similar to the process again, so that until the end of the loop n times, the elements in the array are ordered from small to large. Note: Just go through n-1 sort */public class bubblesort{public static void sort (int[] arrays) {//First loop control n-1 reorder for (int i=0;i<arrays.length-1;i++) {//second loop controls the number of elements to compare each time n-1 for (int j=0;j<arrays.length-i-1;j+ +) {if (arrays[j]>arrays[j+1]) {int flag=arrays[j]; ARRAYS[J]=ARRAYS[J+1]; Arrays[j+1]=flag; }}}} public static void Main (string[] args) {//one-dimensional array definition and initialization int[] scores={90,7 0,50,80,60,85}; Sort (scores); Output sorted scores for (int i=0;i<scores.length;i++) {System.out.print (scores[i]+ ","); } }}
http://www.verejava.com/?id=16992682424030
Java array One dimension array bubble sort algorithm