日期:2014-05-20 浏览次数:20840 次
package eclipsePackage;
public abstract class ListUseArray < DataType > {
protected final static int myINITIAL_SIZE = 1;
protected int myCount;
public int mySize;
protected DataType [] myList;
public ListUseArray() {
myList = (DataType[])new Object[myINITIAL_SIZE];
mySize = myINITIAL_SIZE;
myCount = 0;
}
protected abstract void extendArray() throws ActorsAndMoviesException;
public int getCurrentSize() {
return myCount;
}
public DataType getItemAtIndex(int inIndex) {
return myList[inIndex];
}
public void addItem(DataType inItem) throws ActorsAndMoviesException {
if (myCount == mySize) {
extendArray();
myList[myCount++] = inItem;
}
}
public abstract String toString();
}
package eclipsePackage;
import eclipsePackage.ListUseArray;
// 这个public class ActorList <DataType extends ListUseArray<DataType> >类声明小弟
//摘抄自网上不懂其中含义,不知写的对不对
public class ActorList <DataType extends ListUseArray<DataType> > {
private final static int myMAX_SIZE = 20;
public ActorList() {
super();
}
protected void extendArray() throws ActorsAndMoviesException {
// eclipse报错mySize cannot be resolved to a variable
//不过此变量是protected的呀,小弟真心不懂
if (mySize * 2 <= myMAX_SIZE) {
int i = 0;
}
}
public String toString() {
// eclipse报错mySize cannot be resolved to a variable