在JDK1.5中的Stack的peek()方法的返回类型是E,这个E是什么意思?
在JDK1.4中的Stack的peek()方法的返回类新是object
所以这个E 是请各位给解释解释

解决方案 »

  1.   

    Returns:
    the object at the top of this stack (the last item of the Vector object). 一样是object 啊
      

  2.   

    peek
    public E peek()
    Looks at the object at the top of this stack without removing it from the stack. Returns:
    the object at the top of this stack (the last item of the Vector object). 
    Throws: 
    EmptyStackException - if this stack is empty.
      

  3.   

    1.5中包括stack在内的容器类都是支持范性的,其中的E表示你在定义Stack的型别的时候指定的那个类。如果你指定的是Integer,它就代表Integer,指定String就代表String。