![]() It's important to understand that unlike an array's length property, the ArrayList.size() method returns the actual number of elements, not the original capacity. The list's current size can be found using the size() method: Just keep this in mind for the future (of course, you can pass an array of some specific size that will also work). Inside the ArrayList class, this method is implemented in such a way that passing an empty array increases its performance. Note: we passed an empty array to the toArray() method. We do this using the toArray() method:Ĭat catsArray = cats.toArray(new Cat) You can also go in the opposite direction: get an array from an ArrayList object.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |