qq_冲_0
2016-09-14 20:42
下面是包的错误 朋友们帮我看看
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
CoursesToSelect cannot be resolved
CoursesToSelect cannot be resolved
at com.imooc.cellection.ListTest.testAdd(ListTest.java:18)
at com.imooc.cellection.ListTest.main(ListTest.java:24)
package com.imooc.collection;
import java.util.ArrayList;
import java.util.List;
//备选课程类
public class ListTest1 {
/**
* 用于存放备选课程的list
*/
public List coursesToSelect;
public ListTest1(){
this.coursesToSelect = new ArrayList();
}
/**
* 用于往coursesToSelect中添加备选课程
*/
public void testAdd(){
Course cr1 = new Course("1","数据结构");
coursesToSelect.add(cr1);
Course temp = (Course) coursesToSelect.get(0);
System.out.println("添加课程:"+temp.getId() +":"+temp.getName());
}
public static void main(String[] args) {
ListTest it = new ListTest();
it.addTest();
}
}我帮你改过来了,自己看看吧
package com.imooc.cellection;
import java.util.ArrayList;
import java.util.List;
//备选课程类
public class ListTest {
/**
* 用于存放备选课程的list
*/
public List coursesToSelect;
public ListTest(){
this.coursesToSelect = new ArrayList();
}
/**
* 用于往coursesToSelect中添加备选课程
*/
public void testAdd(){
Course cr1 = new Course("1","数据结构");
CoursesToSelect.add(cr1);
Course temp = CoursesToSelect.get(0);
System.out.println("添加课程:"+temp.id +":"+temp.name);
}
public static void main(String[] args) {
ListTest it = new ListTest();
it.testAdd();
}
}
这是源码
Java入门第三季
409776 学习 · 4546 问题
相似问题