Creating a new ArrayList in Java

后端 未结 9 1744
执念已碎
执念已碎 2021-02-05 00:31

Assuming that I have a class named Class,

And I would like to make a new ArrayList that it\'s values will be of type Class.

My question

9条回答
  •  一向
    一向 (楼主)
    2021-02-05 00:52

    You are looking for Java generics

    List list = new ArrayList();
    

    Here's a tutorial http://docs.oracle.com/javase/tutorial/java/generics/index.html

提交回复
热议问题