简体   繁体   中英

How do you wait to initialize an array until you know the length?

I want to create a series of 6 parallel arrays that are global variables to store file input, but I won't know how long they are meant to be until I've processed a part of the input. Is there a way to delay the initialization of an array until I've processed the length of the array?

It is possible to initialize a variable then give it a value later.

int[] myArray;
//... Do stuff.
myArray = new int[theLengthIWant];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM