问候Java Wizzards,
我很难将通用列表从我的测试人员类传递到我的主类。此分配的目的是将列表中的最后一个元素移动到列表中的第一个位置,并将列表的其余成员右移一个单元。目前,当我运行测试仪时,我收到以下错误。
无法找到jre1.8.0_20的可执行文件。
非常感谢任何帮助。
import java.util.Arrays;
public class Task1<E> {
/*
* implement a method for KWArrayList(as a generic) that removes an elements fron the end of
* the list and inserts it at the lists beginning
*
* 2. following example of section 2.3, do not invoke other KWArrayList methods.
*
* 3. Write a test program proving that it works for ArrayLists having sizes 1,2,5
*
* 4. upload class and test class zipped together.
*/
private static final int INITIAL_CAPACITY = 10;
private E[] theData;
private int capacity = 0;
@SuppressWarnings("unchecked")
public Task1() {
capacity = INITIAL_CAPACITY;
theData = (E[]) new Object[capacity];
}
public void frontOfTheLine(Object item ){
int end = theData.length - 1;
theData[0]=theData[end];
for (int i = end; i>0 ;i--)
{
theData[i]= theData[i-1];
}
for(int counter = 0;counter< theData.length;counter++)
System.out.printf( "%5d%8d\n",counter,theData[counter]);
}
}
public class Task1Tester {
private static Object item1;
public static void main(String[] args) {
// we need a test array of length 1, 2, and 5
Task1<Object> theData = new Task1<Object>();
item1 = "a";
theData.frontOfTheLine(item1);
}
}