Creating a new ArrayList in Java

后端 未结 9 1738
执念已碎
执念已碎 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 01:05

        ArrayList myArray = new ArrayList();
    

    Here ArrayList of the particular Class will be made. In general one can have any datatype like int,char, string or even an array in place of Class.

    These are added to the array list using

        myArray.add();
    

    And the values are retrieved using

        myArray.get();
    

提交回复
热议问题