ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[https://www.jianshu.com/p/1458abf81adf](https://www.jianshu.com/p/1458abf81adf) ~~~ private void sort(int[] nums) { if (null == nums || nums.length == 0) { throw new RuntimeException("array is empty"); } for (int i = 0; i < nums.length - 1; i++) { boolean flag = true; for (int j = 0; j < nums.length - i - 1; j++) { if (nums[j] > nums[j + 1]) { int temp = nums[j]; nums[j] = nums[j + 1]; nums[j + 1] = temp; flag = false; } } if (flag) break; } } ~~~