java实列化十个学生,按分数排序
答案:2 悬赏:0
解决时间 2021-02-28 07:57
- 提问者网友:北故人
- 2021-02-28 03:21
最佳答案
- 二级知识专家网友:转身→时光静好
- 2021-02-28 03:36
public class Demo {
public static void main(String args[])
{
Student[] s = new Student[10];
for(int i=0;i
s[i]=new Student((101+i)+"","Tom"+(i+1),(int)(Math.random()*100));
}
System.out.println("未排序前:");
print(s);
for(int i =0;i
for(int j =i;j
if(s[i].getChengji()
Student ss =s[i];
s[i]=s[j];
s[j]=ss;
}
}
}
System.out.println("排序后:");
print(s);
}
private static void print(Student[] s) {
for(Student as: s)
System.out.println(as);
}
}
class Student {
private String id;
private String name;
private double chengji;
public Student(String id, String name, double chengji) {
this.id = id;
this.name = name;
this.chengji = chengji;
}
public double getChengji() {
return this.chengji;
}
public String toString(){
return "编号:"+this.id+", 名字:"+this.name+",成绩:"+this.chengji;
}
}
public static void main(String args[])
{
Student[] s = new Student[10];
for(int i=0;i
}
System.out.println("未排序前:");
print(s);
for(int i =0;i
s[i]=s[j];
s[j]=ss;
}
}
}
System.out.println("排序后:");
print(s);
}
private static void print(Student[] s) {
for(Student as: s)
System.out.println(as);
}
}
class Student {
private String id;
private String name;
private double chengji;
public Student(String id, String name, double chengji) {
this.id = id;
this.name = name;
this.chengji = chengji;
}
public double getChengji() {
return this.chengji;
}
public String toString(){
return "编号:"+this.id+", 名字:"+this.name+",成绩:"+this.chengji;
}
}
全部回答
- 1楼网友:万千宠爱
- 2021-02-28 04:40
很简单、 具体的例子我木有、。。 这个东西还是需要你自己去写一下的呀。。。 你用的是分页标签么,当点击下一页的时候、 就去执行一个ajax请求、 取出数据、放入request中、然后页面就更新数据了。。
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯
• 手机登qq时,显示手机磁盘不足,清理后重新登 |
• 刺客的套装怎么选啊? |