标签:tostring size 移动 针对 最大值 静态 after jpg str
1 package com.led.sort; 2 3 import java.util.Arrays; 4 5 /** 6 * Bubble Sort: Digital from small to large 7 * 8 * @author Lin_Hero 9 * 10 */ 11 public class Bubble001 { 12 13 public static int[] BubbleSort(int[] a) { 14 15 int temp; 16 for (int i = 0; i < a.length; i++) { 17 for (int j = i + 1; j < a.length; j++) { 18 if (a[i] > a[j]) { 19 temp = a[i]; 20 a[i] = a[j]; 21 a[j] = temp; 22 } 23 } 24 } 25 return a; 26 } 27 28 public static void main(String[] args) { 29 30 int[] array = { 1, -6, -99, 67, 45, 8, 0, -90 }; 31 System.out.println("Before bubble sort:"); 32 System.out.println(Arrays.toString(array)); 33 34 Bubble001.BubbleSort(array); // 静态方法的调用:类名.方法名 35 System.out.println("After bubble sort:"); 36 System.out.println(Arrays.toString(array)); 37 38 } 39 40 }
控制台输出:
Before bubble sort: [1, -6, -99, 67, 45, 8, 0, -90] After bubble sort: [-99, -90, -6, 0, 1, 8, 45, 67]
标签:tostring size 移动 针对 最大值 静态 after jpg str
原文地址:http://www.cnblogs.com/stm32stm32/p/6421738.html