public class ArrayReverse {
private LinkedList<Integer> li = new LinkedList<Integer>();//存储预操作数组
private LinkedList<Integer> result = new LinkedList<Integer>(); //存储结果数据
public static void main(String[] args) {
int [] array ={1,2,3,4,5,6,7};
ArrayReverse ar = new ArrayReverse();
ar.put(array);
ar.dReverse(3); //删除4
ar.show(); //输出5,6,7,1,2,3
}
public void put(int [] array){
for(int num : array){
li.add(num);
}
}
public void dReverse(int index){
if(index>li.size())
throw new RuntimeException("已超出当前容器容量");
for(int j =index+1;j<li.size();j++){
result.add(li.get(j));
}
for(int i =0;i<index;i++){
result.add(li.get(i));
}
}
public void show(){
Iterator<Integer> it = result.iterator();
while(it.hasNext()){
System.out.print(it.next()+" ");
}
}