package JA;
import java.util.Arrays;
public class TestArrayTabe {
public static void main(String[] args) {
Object[] emp1={1001,"高淇",18,"讲师","20006.6.6"};
Object[] emp2={1001,"高2淇",18,"讲师","20006.6.6"};
Object[] emp3={1001,"高3淇",18,"讲师","20006.6.6"};
Object[][] tableData=new Object[3][];
tableData[0]=emp1;
tableData[1]=emp2;
tableData[2]=emp3;
for(Object[] temp:tableData){
System.out.println(Arrays.toString(temp));
}
}
}
?冒泡排
import java.util.Arrays;
//测试冒泡排序以及优化
public class TestBubbleSort {
public static void main(String[] args) {
int[] values={3,1,6,9,0,7,4,5,8};
int temp=0;
for(int i=0;i<values.length-1;i++) {//总共找的次数
boolean flag=true;
for (int j = 0; j < values.length - 1-i; j++) {//找最大
//比较大小 换顺序
if (values[j] > values[j + 1]) {
temp = values[j];
values[j] = values[j + 1];
values[j + 1] = temp;
flag=false;
}
System.out.println(Arrays.toString(values));
}
if(flag){
break;
}
System.out.println("###########");
}
}
}
序
|