How to set the size of an array on runtime in java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to set the size of an array on runtime in java

9th Apr 2019, 3:37 PM
Ronak Paul
Ronak Paul - avatar
3 Answers
+ 4
Do you mean to create an array at runtime with number of elements specified from user input, or you mean to resize an array that is already created at runtime? for the latter I think it's not possible.
9th Apr 2019, 5:13 PM
Ipang
+ 1
Unlike python you can't do that in Java... But you can use e.g. ArrayList instead : )
9th Apr 2019, 4:40 PM
Nonea
Nonea - avatar
+ 1
ok
10th Apr 2019, 7:53 AM
Ronak Paul
Ronak Paul - avatar