linkedList.get(i)得到的对象是Object,你要强制转换 Integer b = (Integer )intCollection.get(i);

解决方案 »

  1.   

    是啊!java中的存储结构大多存储的是Object型别,要恢复到原来的性别就需要强制转换转化为原来的性别!
      

  2.   

    Container中存放的都是Object Reference
    不像C++中,在定义容器时就指定了对象类型。
    这是Java的优点也是缺点:)
      

  3.   

    十分感谢大家啊~~转化成功~~
    不过还有个小问题怎么把这个LinkedList intCollection 里面的东西拷贝到一个数组里面呢?用toArray()??好像不行啊。。
      

  4.   

    对了,拷贝完以后如何将那个LinkedList 从内存中释放掉呢?
      

  5.   

    释放空间:
    LinkedList intCollection = .........
    intCollection = null;   // 强制jvm收回intCollection所占的空间
      

  6.   

    转数组:
    Integer aa[] = (Integer [])intCollection.toArray();
      

  7.   

    如果记得没有错的话
    把intCollection里面的某一个位置的东西取出来另一法(jdk 1.5)
    LinkedList <Integer> intCollection = .....
    Integer aa = intCollection.get(i);
      

  8.   

    Integer b[] = intCollection.toArray();
      

  9.   

    纠正一下  cfsego(陈传文)  和  Goal3(拼命三郎) 的写法 :
    转数组因该是这样:"Integer aa[] = (Integer [])intCollection.toArray(new Integer[0]);你不给toArray参数的话 运行时一定会报错的!!!!具体可以参考jdk帮助文档