creating array without declaring the size - java

后端 未结 6 1138
面向向阳花
面向向阳花 2020-12-13 16:29

i\'ve digging around about the same issue but i couldn\'t find the same as i had

i want to create an array without declaring the size because i don\'t know how it w

6条回答
  •  北海茫月
    2020-12-13 16:52

    Using Java.util.ArrayList or LinkedList is the usual way of doing this. With arrays that's not possible as I know.

    Example:

    List unindexedVectors = new ArrayList();
    
    unindexedVectors.add(2.22f);
    
    unindexedVectors.get(2);
    

提交回复
热议问题