Student.java:import java.util.*;
public class Student
{
private int id;
private String name;
private int chinese;
private int math;
private int english;
static TreeMap mapChinese=new TreeMap();
static TreeMap mapStu=new TreeMap(); public Student(int id,String name,int chinese,int math,int english)
{
this.id=id;
this.name=name;
this.chinese=chinese;
this.math=math;
this.english=english;
mapChinese.put(chinese, this); //这句提示错误???????????????
mapStu.put(name, this);
}
public String toString() {
return("学号:"+id+"姓名:"+name+"语文成绩:"+chinese+"数学成绩:"+math+"英语成绩"+english);
}
}==============================myMain.java:import java.util.*;public class myMain { /**
* @param args
*/
public static void sortChinese()
{
for(Iterator it=Student.mapChinese.keySet().iterator() ; it.hasNext(); )
{
System.out.println(Student.mapChinese.get(it.next()));
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Student stu1=new Student(1,"aaa",88,99,89);
Student stu2=new Student(2,"bbb",56,36,56);
Student stu3=new Student(3,"ccc",96,89,87);
System.out.println(Student.mapStu.get("aaa")); //通过名字查询详细信息
sortChinese(); //语文成绩排序 }}
===========================提示错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method put(Object, Object) in the type TreeMap is not applicable for the arguments (int, Student) at Student.<init>(Student.java:19)
at myMain.main(myMain.java:18)
mapChinese.put()里的2个参数是Object类型的,我想放什么就放什么进去,他还提示我不准放(int, Student)型的
真TM搞笑?????????????????
public class Student
{
private int id;
private String name;
private int chinese;
private int math;
private int english;
static TreeMap mapChinese=new TreeMap();
static TreeMap mapStu=new TreeMap(); public Student(int id,String name,int chinese,int math,int english)
{
this.id=id;
this.name=name;
this.chinese=chinese;
this.math=math;
this.english=english;
mapChinese.put(chinese, this); //这句提示错误???????????????
mapStu.put(name, this);
}
public String toString() {
return("学号:"+id+"姓名:"+name+"语文成绩:"+chinese+"数学成绩:"+math+"英语成绩"+english);
}
}==============================myMain.java:import java.util.*;public class myMain { /**
* @param args
*/
public static void sortChinese()
{
for(Iterator it=Student.mapChinese.keySet().iterator() ; it.hasNext(); )
{
System.out.println(Student.mapChinese.get(it.next()));
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Student stu1=new Student(1,"aaa",88,99,89);
Student stu2=new Student(2,"bbb",56,36,56);
Student stu3=new Student(3,"ccc",96,89,87);
System.out.println(Student.mapStu.get("aaa")); //通过名字查询详细信息
sortChinese(); //语文成绩排序 }}
===========================提示错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method put(Object, Object) in the type TreeMap is not applicable for the arguments (int, Student) at Student.<init>(Student.java:19)
at myMain.main(myMain.java:18)
mapChinese.put()里的2个参数是Object类型的,我想放什么就放什么进去,他还提示我不准放(int, Student)型的
真TM搞笑?????????????????
解决方案 »
- HttpURLConnection的问题
- 这段代码问题出在哪里?
- JDBC的疑问??!!
- 各位牛人:我求用ant将文件上传到远程ftp服务器的指定目录的方法!
- 有没有关于万年历的算法或者程序?不好意思,上一帖分送少了,现在补!
- 急!!如何用udp协议传输大文件??谢谢
- 一个jni的问题
- eclipse生成jar文件,想要把配置文件单独放在外面,试了好久没成功
- 怎样故意让FileOutputStream.close()抛出异常?
- 有只用forte 2.0的高手吗?请指教
- Hibernate+Tomcat的pool exhausted问题
- 关于Java 程序编译的问题 两个Java程序互相使用对方的类,请问详细的编译过程是如何实现的
应该是JCreator编译时把错误检查等级调低了
1.5
int 可以转成Integer 谢谢