类型已定义的问题,搞不定啊!
源代码如下
package test1;
import java.util.*;
class Student
{
	public int id;
	public String name;
	public int math_score;
	public int english_score;
	public int computer_score;	
	public Student(int id,String name,int math_score,int english_score,int computer_score)
	{
		this.id=id;
		this.name=name;
		this.math_score=math_score;
		this.english_score=english_score;
		this.computer_score=computer_score;
	}	
}
public class MapTest  
{
	public static void main(String[] args)  
	{
		TreeMap<Integer,Student> map=new TreeMap<Integer,Student>();
		int total=0;
		int[] grade=new int[5];
		Student[] s=new Student[5];
		s[0]=new Student(100001,"王军",85,75,95);
  	    s[1]=new Student(100002,"李吉",90,70,80);
  	 	s[2]=new Student(100003,"殷红",92,80,80);
  		s[3]=new Student(100004,"玛丽",80,87,76);
  		s[4]=new Student(100005,"刘艳",80,70,60);		
		map.put(100001,s[0]);
  		map.put(100002,s[1]);
  		map.put(100003,s[2]);
  		map.put(100004,s[3]);
  		map.put(100005,s[4]);	
		int[] arr=new int[5];
		int i=0;     		
		int j=Integer.parseInt(args[0]);  //将字符串转换成整形
		System.out.println("学号	姓名	计算机成绩	数学成绩	英语成绩	总学分");		
		if(map.containsKey(j))
		{
			System.out.println("你要查找的学生信息是: ");
			Student stu=map.get(j);							//从容器中取出一个学生
			System.out.println(stu.id+"	");
			System.out.println(stu.name+"            ");
			System.out.println(stu.computer_score+"              ");
			System.out.println(stu.english_score+"               ");
			System.out.println(stu.math_score+"                 ");
			total=stu.computer_score+stu.english_score+stu.math_score;
			System.out.println(total);
		}
		System.out.println();
		TreeMap<Integer,Student> tp=new TreeMap<Integer,Student>();
		Iterator<Map.Entry<Integer,Student>> it=map.entrySet().iterator(); //返回一个迭代器		
		System.out.println("按总学分排序前:");
		while(it.hasNext())
		{
			@SuppressWarnings("rawtypes")
			Map.Entry entry=it.next();
			arr[i]=(Integer)entry.getKey();
			s[i]=(Student)entry.getValue();			
			System.out.println(s[i].id+"   ");
			System.out.println(s[i].name+"     ");
			System.out.println(s[i].computer_score+"  ");
			System.out.println(s[i].english_score+"   ");
			System.out.println(s[i].math_score+"      ");
			total=s[i].computer_score+s[i].english_score+s[i].math_score;
			System.out.println(total);
			System.out.println();
			grade[i]=total;
			tp.put(grade[i],s[i]);
			i++;
		}	
	}
}
还没运行之前是  错误信息是  The type Student is already defined
然后运行之后是                
Exception in thread "main" 
java.lang.NoSuchMethodError: test1.Student.<init>(ILjava/lang/String;III)V
	at test1.MapTest.main(MapTest.java:33)
然后我请教了下身边的人
他们说是  int j=Integer.parseInt(args[0]);  //将字符串转换成整形
这句话有问题   
不知道怎么解决啊   
谢谢你们了
------解决方案--------------------我直接贴你的代码,没有报错啊,你看看是不是别的地方多定义了一个Student类;
后面的那个错误,是没有找到main方法,代码里面是有了的,你注意看看环境变量配置得对不对;
http://hi.baidu.com/zhuzejiang/item/cfda93108a77cc9e98ce331b
int j=Integer.parseInt(args[0]);
这一行有可能会出现问题,你要是再eclipse里运行,需要往main方法里传递参数。不要直接run java application,要选Run Configurations这个选项,然后点进去之后的argument设置参数,100001啊什么的。
------解决方案--------------------int j=Integer.parseInt(args[0]); //将字符串转换成整形 你这句是干嘛用的 完全可以删掉啊,你要实现什么?