java开发中remove()删除无效?

package example02;

public class Phone {
	public Phone(String name, String color, double price, int num) {
		// TODO Auto-generated constructor stub
		this.name=name;
		this.color=color;
		this.price=price;
		this.num=num;
	}
	private String name;
	private String color;
	private double price;
	private int num;
	public String getName() {
		// TODO Auto-generated method stub
		return this.name;
	}
	public String getColor() {
		// TODO Auto-generated method stub
		return this.color;
	}
	public double getPrice() {
		// TODO Auto-generated method stub
		return this.price;
	}
	public int getNum() {
		// TODO Auto-generated method stub
		return this.num;
	}
	
}
package example02;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Scanner;
import java.util.List;
class Head{
	public Head() {
		System.out.println("欢迎使用库房管理系统,请选择要运行的操作:");
		System.out.println("1.商品入库");
		System.out.println("2.商品显示");
		System.out.println("3.删除商品");
	}
}

public class example01 {
	static ArrayList<Phone> c = new ArrayList();
	public static void main(String[] args) {	
		// TODO Auto-generated method stub
		c.add(new Phone("小米3","玫瑰金",3999.00,15));
		c.add(new Phone("小米2","玫金",3777,15));
		c.add(new Phone("小米11","金",3999,18));
		c.add(new Phone("小米7","瑰金",3699,95));
		c.add(new Phone("小米9","瑰金",3499,33));
		while(true) {
			Head head = new Head();
			Scanner sc = new Scanner(System.in);
			int s = sc.nextInt();
			if(s == 1) {
				addwarehouse();
				System.out.println("商品录入成功,入库后仓库商品如下:");
				warehouse();
				System.out.println("作者:41+黄丽君");
			}else if(s == 2) {
				warehouse();
			}else if(s == 3) {
				System.out.println("请输入你要删除的商品编号:");
				int index = sc.nextInt();
				delwarehouse(index);
				System.out.println("商品录入成功,入库后仓库商品如下:");
				warehouse();
				
			}else {
				System.out.println("操作失败!!!");
				
			}
		}
		
	}
	private static void addwarehouse() {
			while(true) {
				
				System.out.println("您是否录入商品?");
				Scanner w = new Scanner(System.in);
				String s = w.next();
				if(s.equals("yes")) {
					Scanner scl = new Scanner(System.in);
					System.out.println("请输入商品得到名称:");
					String name = scl.next();
					System.out.println("请输入商品得到颜色:");
					String color = scl.next();
					System.out.println("请输入商品得到价格:");
					int p = scl.nextInt();
					System.out.println("请输入商品得到数量:");
					int n = scl.nextInt();
					c.add(new Phone(name,color,p,n));
					break;
				}else {
					System.out.println("作者:41+黄丽君");
					break;
				}
			}
		}
	private static void warehouse() {
		Iterator it = c.iterator();
		while(it.hasNext()) {
			Phone s = (Phone)it.next();
			System.out.println(s.getName()+"..."+s.getColor()+"..."+s.getPrice()+"..."+s.getNum());
			}
		}
	private static void delwarehouse(int index) {
			c.remove(index);

		}
}

 

打印或调试一下index的值是多少,不可能无效的。