public class Arr {
public static void main(String[] args) {
String [] a = {"one","two","three","four"};//定义变量
String temp;
for(int i=1;i<a.length;i++){
for(int j=0;j<a.length-i;j++){
if((a[j]).contentEquals(a[j+1])){
temp = a[j];
a[j] = a[j+1];
a[j+1]=temp;
}
}
}
for(int i=0;i<a.length;i++){
System.out.println(a[i]);
}
}
}
谁的一句来日方长 让我目睹了人走茶凉
本文提供了一个使用Java实现的简单冒泡排序算法示例,通过对字符串数组进行排序展示了冒泡排序的基本原理。
6574

被折叠的 条评论
为什么被折叠?



