容器的比较
来源:互联网 发布:网络机顶盒app下载 编辑:程序博客网 时间:2024/06/07 03:47
package 第11章;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
class Stu implements Comparable<Stu> {
private int id;
/**
* @return the id
*/
public int getId() {
return id;
}
public Stu(int id, int score, String name) {
this.id = id;
this.score = score;
this.name = name;
}
/**
* @param id
* the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the score
*/
public int getScore() {
return score;
}
/**
* @param score
* the score to set
*/
public void setScore(int score) {
this.score = score;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
private int score;
private String name;
@Override
public String toString() {
return "id=" + this.id +" "+ "score=" + this.score + " "+"name=" + this.name;
}
@Override
public int compareTo(Stu o) {
// TODO Auto-generated method stub
return this.score - o.score;
}
}
public class DataDemo7 {
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
public static void main(String[] args) {
Stu[] stus = { new Stu(1, 50, "1"), new Stu(2, 20, "2"),
new Stu(3, 40, "3"), new Stu(4, 40, "4"), new Stu(5, 10, "5") };
Arrays.sort(stus);
for(int i=0;i<stus.length;i++)
{
List<Stu> list=new ArrayList<Stu>();
list.add(stus[i]);
System.out.println(list.toString());
}
}
}
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
class Stu implements Comparable<Stu> {
private int id;
/**
* @return the id
*/
public int getId() {
return id;
}
public Stu(int id, int score, String name) {
this.id = id;
this.score = score;
this.name = name;
}
/**
* @param id
* the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the score
*/
public int getScore() {
return score;
}
/**
* @param score
* the score to set
*/
public void setScore(int score) {
this.score = score;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
private int score;
private String name;
@Override
public String toString() {
return "id=" + this.id +" "+ "score=" + this.score + " "+"name=" + this.name;
}
@Override
public int compareTo(Stu o) {
// TODO Auto-generated method stub
return this.score - o.score;
}
}
public class DataDemo7 {
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
public static void main(String[] args) {
Stu[] stus = { new Stu(1, 50, "1"), new Stu(2, 20, "2"),
new Stu(3, 40, "3"), new Stu(4, 40, "4"), new Stu(5, 10, "5") };
Arrays.sort(stus);
for(int i=0;i<stus.length;i++)
{
List<Stu> list=new ArrayList<Stu>();
list.add(stus[i]);
System.out.println(list.toString());
}
}
}
0 0
- 轻量级容器的比较
- 轻量级容器的比较
- 容器的比较
- 顺序容器和关联容器的比较
- 容器的比较和字符串的比较
- STL容器的效率比较
- STL容器的效率比较
- C++容器:容器比较
- 顺序容器和关联式容器的比较
- 第十一章 顺序容器和关联容器的比较
- Java中Arraylist容器与Vector容器的比较
- Java中Arraylist容器与Vector容器的比较
- 关于几个常用容器类型的比较
- Servlet容器:Jetty和tomcat的比较
- STL 中各容器的比较
- 两个库的any容器比较
- JAVA中容器和数组的比较
- STL:如何理解容器对象的比较
- poll在用户空间与驱动中的交互及使用事项
- 开发文档生成工具--Doxygen
- unity 导出 android安装包配置方案
- ContentProvider和其他应用共享数据
- 国人当自强:两岸三地在线编程学习网站大搜罗
- 容器的比较
- MVC中modelstate的用法
- 1、DLL基本理论
- UIColor 转 UIImage
- 用JAVA编写MP3解码器——GUI
- 17周项目二,7,(指针做形参) .
- vptr被设置内容的时机
- CSharp学习笔记之九 多线程编程
- Maven3项目构建