Using combined strings as istance name
in
Programming Questions
•
2 years ago
Hi,
being a super noob in programming i was trying to give a class instance a name generated by a for cycle.
now, the problem is that in both the line of code i wrote (line 7 and 8) Processing doesn't read the id as i want to (i.e. q1, q2, q3).
is there a way to tell processing to use a mix of 2 or plus strings as an instance name?
Thank you.
- for (int i = 1; i <= 4; i++) {
- String letter = "q";
- String num = str(i);
- String mix = letter+num;
- println(mix);
- str(q+i).display(); // just read q as istance name don't consider the i
- mix.display(); // of course uses the word mix as the id
- }
1