技术:java8
运行环境:IDEA 15.2 + jdk8 + windows 10
demo功能:java实现一个冒泡排序
public void bubbleSort(int[] arr) {
if (arr == null || arr.length == 0) {
return;
}
while (true) {
boolean finished = true;
for (int i = 0; i <= arr.length - 1; i++) {
if (i == arr.length - 1) {
break;
}
if (arr[i] > arr[i + 1]) {
int max = arr[i];
arr[i] = arr[i + 1];
arr[i + 1] = max;
finished = false;
}
}
if (finished) {
break;
}
}
for (int i = 0; i <= arr.length - 1; i++) {
System.out.println(arr[i]);
}
}
欢迎添加微信,互相学习↑↑↑ -_-
白老虎
programming is not only to solve problems, ways to think
grafana 级连 菜单 templating (variables) 配置
AI 机器人 抓取 微信 聊天中的 百度网盘 分享地址和密码
rocketmq 集群搭建 (2master + 2slave + 2namesrv)