帮忙看看拿错了

来源:4-4 学生选课---添加课程 Ⅰ

liu4444

2016-01-07 15:47

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;

}

}


写回答 关注

1回答

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

    主函数错了

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


    liu444...

    非常感谢!

    2016-01-08 08:24:24

    共 1 条回复 >

Java入门第三季

Java中你必须懂得常用技能,不容错过的精彩,快来加入吧

409792 学习 · 4340 问题

查看课程

相似问题