java api文档中有些地方写着<E>是什么意思?
例如:public class Stack<E> extends Vector<E>

解决方案 »

  1.   

    java5中的泛型用法
    使用时使用实际的类名称来替代
    如Stack<String>
      

  2.   

    Here is a simple example taken from the existing Collections tutorial: // Removes 4-letter words from c. Elements must be strings
    static void expurgate(Collection c) {
        for (Iterator i = c.iterator(); i.hasNext(); )
          if (((String) i.next()).length() == 4)
            i.remove();
    }Here is the same example modified to use generics: // Removes the 4-letter words from c
    static void expurgate(Collection<String> c) {
        for (Iterator<String> i = c.iterator(); i.hasNext(); )
          if (i.next().length() == 4)
            i.remove();
    }
      

  3.   

    啊,java也学c++用模板了,java不是不支持模板的吗。我第一次见到,谢谢,让我增长见识了。
      

  4.   

    最新版的J2SE开始支持的.不光JAVA开始支持泛型,连.NET(主要是指C#)也开始支持泛型了(在Microsot FrameWork 2.0中)
      

  5.   

    难怪我在原码中经常见到
    Class<?> 之类的东西哦
    学到东西了
    呵呵