交换两个对象
//問題二:使用冒泡排序按學生成績排序,并遍歷所有學生信息for(int i = 0;i < stus.length - 1;i++){for(int j = 0;j < stus.length - 1 - i;j++){if(stus[j].score > stus[j + 1].score){//如果需要換序,交換的是數組的元素:Student對象!!!Student temp = stus[j];stus[j] = stus[j + 1];stus[j + 1] = temp;}}}
總結
- 上一篇: 月字的来历 月字的由来
- 下一篇: 面向对象VS面向过程