metadata - "Metaaccess" of Objects in Java With Variables in the Identifiers -
i want access number of objects in java without write lot of code, example:
int x; for(x=0;x<5;x++){ jlabelx = /*do something*/ } would this:
when x=0 jlabel0 access, x=1 jlabel1 , on...
is there way of doing this? or need specify cases
the best way of doing not have variables called jlabel0, jlabel1 etc in first place. instead, have array variable (or other collection):
jlabel[] labels = new jlabel[5]; (int = 0; < labels.length; i++) { labels[i] = new jlabel(); // whatever you can @ fields reflection, time see variables x0, x1, x2 etc shudder - it's clear indication collection of kind better fit.
Comments
Post a Comment