- Java (and some libraries as well) offers several types of containers besides its vanilla array
[].
Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/util/doc-files/coll-overview.html - We should choose a container that best fits our needs.
- In your particular case, you need a container that holds
intelements:int data[]={0}; - But at the same time, you need to increase its length size() later:
data[imsi++]=key; - So the most appropriate container for that would be an IntList:
Processing.org/reference/IntList.html
3 Likes