Using and declaring generic List

前端 未结 3 1643
离开以前
离开以前 2020-12-10 11:50

So I\'m working in Java and I want to declare a generic List.

So what I\'m doing so far is List list = new ArrayList();

But no

3条回答
  •  孤城傲影
    2020-12-10 12:16

    The T is the type of the objects that your list will contain. You can write List and use it in a function which needs List, it shouldn't be a problem since the T is used to say that it can be anything.

提交回复
热议问题