CoursesToSelect.add(cr1); Course temp = CoursesToSelect.get(0); 報(bào)錯(cuò)了
下面是包的錯(cuò)誤 朋友們幫我看看
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)
2016-09-17
我?guī)湍愀倪^(guò)來(lái)了,自己看看吧
2016-09-14
package com.imooc.cellection;
import java.util.ArrayList;
import java.util.List;
//備選課程類(lèi)
public class ListTest {
/**
* 用于存放備選課程的list
*/
public List coursesToSelect;
public ListTest(){
this.coursesToSelect = new ArrayList();
}
/**
* 用于往coursesToSelect中添加備選課程
*/
public void testAdd(){
Course cr1 = new Course("1","數(shù)據(jù)結(jié)構(gòu)");
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();
}
}
這是源碼