本帖最后由 lxmxrx 于 2010-04-20 14:51:12 编辑

解决方案 »

  1.   

    Student student = new Student(studentName, course[5],score[5]);-->Student student = new Student(studentName, course,score);
      

  2.   

    正解
    course[5],score[5]这两个参数传错了,应该传递数组的引用(即数组名).你把course[5]当成整个数组了,其实couuse[int x]这只是数组里的一个值。
      

  3.   

    上面有很多错误,重新编译后是这样的public class Student {
    private String studentName;
        private String[] courseName;
        private int[]  courseScore;
        public Student(String studentName,  String[] courseName,int[] courseScore) {
            this.studentName = studentName;
            this.courseName = courseName;
            this.courseScore = courseScore;
        }
        private int sum() {
            int sum = 0;
            for(int i=0; i<courseScore.length; i++) {
                sum += courseScore[i];
            }
            return sum;
        }
        private double avg() {
            return this.sum() / courseScore.length;
        }
        public void printStudentInfo() {
            System.out.println("StudentName:\t\t" + studentName);
            for(int i=0; i<courseScore.length; i++) {
                System.out.println(courseName[i] + ":\t\t" + courseScore[i]);
            }
            System.out.println("TotalScore:\t\t" + this.sum());
            System.out.println("Average:\t\t" + this.avg());
        }}
    public class MainClass { /**
     * @param args
     */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    String studentName = "James.King";
            String[] course = new String[]{"courseA","courseB","courseC","courseD","courseE"};
            int[] score = new int[]{60,70,80,85,90};
            Student student = new Student(studentName, course[5],score[5]);
            student.printStudentInfo(); }}
      

  4.   

    楼主在玩人吧!public Student(String studentName,  String[] courseName,int[] courseScore;)(你带个分号干吗?难道在你工程里面没报错!)Student student = new Student(studentName, course[5],score[5]);你的构造 怎么写的 放的是数组  你调用的时候 怎么的就用 数组的原数? 我真是佩服你! 玩人这样玩啊...你String a[]=B[5]; 这样去玩玩吧 看看报错不!String[] course = new String{"courseA","courseB","courseC","courseD","courseE"};
    int[] score = new int{60,70,80,85,90};可以这样new 出来? 你使用的是什么工具?难道这样的代码不报错?
      

  5.   

    对不起,各位,刚才是在UtralEdit中写出来的。没有编译过。有很多错误。已经修改了。4楼为正解。