Create a variable variable | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Create a variable variable

I want to create a program with while and I need that every time that run the while create a new variable. Something like: while(something){ int variableX; x++; } X gonna be a number changing and create variables like: variable1, variable2, variable3... Please help me or say if this is possible. Sorry about the bad english.

4th Oct 2017, 12:01 AM
Gabriel Pereira
Gabriel Pereira - avatar
1 Answer
+ 1
you have to use the "new" key word in combination with an arrays
4th Oct 2017, 12:08 AM
Nura Programmer
Nura Programmer - avatar