How to create a class that implements java.util.collections

后端 未结 6 782
深忆病人
深忆病人 2021-02-10 09:46

I am trying to create a class say MyStack that would implement a java.util.collections class. MyStack will override some methods of the collections cl

6条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-10 10:38

    You were VERY close!

    You just need to define E in your subclass as well:

    public class MyStak implements java.util.Collection
    

    The idea is that you could have a subclass with, say, , and you implement two different interfaces, one using E, one using F. That, or MyStak could be specialized and use a specific class for Collection, instead of a generic E.

提交回复
热议问题