问答详情
源自:4-4 学生选课---添加课程 Ⅰ

帮忙看看拿错了

package aaaa.imooc3;


import java.util.ArrayList;

import java.util.List;


public class ListTest {

public List coursesToSelect;

public ListTest(){

this.coursesToSelect = new ArrayList();

}

public void testAdd(){

Course cr1 = new Course("1","数据结构");

coursesToSelect.add(cr1);

Course temp= (Course) coursesToSelect.get(0);

System.out.println("添加了课程:" + temp.id + ":" + temp.name);

}

public static void main(String args){

ListTest lt = new ListTest();

lt.testAdd();

}

}




package aaaa.imooc3;


import java.util.HashSet;

import java.util.Set;


public class Student {

public String id;

public String name;

public Set courses;

public Student(String id,String name){

this.id = id;

this.name = name;

this.courses = new HashSet();

}

}





package aaaa.imooc3;


public class Course {

public String id;

public String name;

public Course(String id,String name){

this.id = id;

this.name = name;

}

}


提问者:liu4444 2016-01-07 15:47

个回答

  • 宝慕林5235068
    2016-01-07 21:31:12
    已采纳

    主函数错了

    public static void main(String[] args){
    }