java: ArrayList - how can i check if an index exists? -
I ArrayList & lt; String & gt; I'm using and I add data to a specific index, I check whether a specific index exists?
Should I just get () and check the value? Or should I wait for an exception? Is there any other way?
Update
Thank you for your reply, but because I'm only adding stuff to a specific index, the length of the list will not be visible to me which are available.
method arrayList.size () number of items in the list - therefore if If the index is equal to or equal to size () , then it does not exist.
Comments
Post a Comment