+ 5
How to define size of an Array at run-time in C++ / Java?
I know that we have to define size of an Array before the run-time using a constant or a number. But, consider a case in which we have to define it on-the-fly then, how could we achieve that. Any ideas?
5 Réponses
+ 10
Okay, wrote a simple example for ArrayList:
https://code.sololearn.com/cGkFIZqQ4xw3/?ref=app
+ 9
Java: You could use an ArrayList or another list implementation. Simple as that ;)
+ 4
Tashi N, an example would be helpful :)
I have just started Java and still covering the basics!
+ 2
In C++ you can use the keword "new". You have to access it via pointer:
int* arrptr = new int[size];
don't forget to delete it with:
delete[ ] arrptr;
https://code.sololearn.com/c6b4Dszb2066/?ref=app
0
what is the difference between println and print?