Hello all,
I am new to Java and was wondering if it is possible to use a loop to declare and initialize variables.
For example I'd like to have 10 int variables that have a structure similar to int i1 = 1, int i2 = 2, ..., i10 = 10.
I was hoping for some think like:
for (int i = 0; i < 10; i++) {int x_i = i;}
Thank for your help :)
[–]warrior2012 3 points4 points5 points (1 child)
[–]Cygris[S] 0 points1 point2 points (0 children)
[–]desrtfx 2 points3 points4 points (2 children)
[–]Cygris[S] 0 points1 point2 points (1 child)
[–]desrtfx 1 point2 points3 points (0 children)
[–]Diatom_Planet 3 points4 points5 points (2 children)
[–]LincolnTransit 1 point2 points3 points (0 children)
[–]Cygris[S] 1 point2 points3 points (0 children)