Interface List - java

后端 未结 2 1072
小鲜肉
小鲜肉 2021-01-28 14:27

We have been asked to replace ArrayList and use interface List instead in two classes. I\'ve been trying but to no avail. If someone could help with one of the classes to show h

2条回答
  •  -上瘾入骨i
    2021-01-28 14:52

    "List" is an interface, therefore it cannot be instantiated. Replace all declarations that are now ArrayList with List, where x is the class contained by the container. But, leave the instantiation the same (List = new ArrayList(); is valid). It's a simple change but the code you provided is clearly incomplete.

    At the risk of sounding like a troll, you should also tag this "homework" or seek employment elsewhere unless you strongly feel that this change is justified in your code.

提交回复
热议问题