package com.itemuch.cloud.test; import java.io.Serializable; import java.util.Date; import java.util.HashMap; import java.util.Map; public class JavaBasical{ public static void main(String arsg[]){ int[] unSortNums = new int[]{ 1,3,4,5,2,9}; GetSortResult(unSortNums); System.out.println("new Begin"); GetTime(); } /** * @result 获取当前时间 */ private static void GetTime() { Date time = new Date(); System.out.println(time); } /** * * @param nums * @result 获取冒泡排序结果 */ public static void GetSortResult(int[] nums){ for(int i = 0;i < nums.length - 1; i++){外层循环控制排序趟数 for(int j = 0 ;j < nums.length - 1 -i; j++){内层循环控制每一趟排序多少次 if(nums[j] > nums[j+1]){ int temp = nums[j]; nums[j] = nums[j+1]; nums[j+1] = temp; } } } System.out.println("sortResultList:"); for (int num:nums) { System.out.print(" "+num+" "); } System.out.println(); } }