冒泡排序:
package com.review.algorithm; public class BubbleSort { public static void main(String[] args) { String str = "4,3,2,6,7,1,5"; String[] strs = str.split(","); String temp = ""; for (int i = 0; i < strs.length; i++) { for (int j = i + 1; j < strs.length; j++) { if (Integer.parseInt(strs[i]) < Integer.parseInt(strs[j])) { temp = strs[i]; strs[i] = strs[j]; strs[j] = temp; } } } for (int i = 0; i < strs.length; i++) { System.out.println(strs[i]); } } }