Discussion:
How to get the capacity of the ArrayList in Java
Ted Yu
2013-10-31 00:07:35 UTC
Permalink
Hi,
I found this:
http://stackoverflow.com/questions/2497063/how-to-get-the-capacity-of-the-arraylist-in-java


Any better practice ?

Thanks
Douglas Pearson
2013-10-31 00:23:02 UTC
Permalink
It's not intended to be exposed.

If you really need it, I'd go with the reflection approach. In the (very
unlikely) case that ArrayList was rewritten to stop using the field, you'd
get an exception right away that would be simple to pinpoint and fix.

If somebody asks - you can just say you're using Java's dynamic language
features :)

Doug
Post by Ted Yu
**
Hi,
http://stackoverflow.com/questions/2497063/how-to-get-the-capacity-of-the-arraylist-in-java
Any better practice ?
Thanks
Continue reading on narkive:
Loading...