PDA

View Full Version : Java Variable Name Incrementing



MyLegIsCramped
02 Sep 2009, 10:47 PM
Hi all, I was wondering if anyone could tell me how to increment a variable name in a for loop. heres an example.



for (i = 0, i < 10, i++)

{

System.out.println("input letter");
String letter0 = input.nextLine();

System.out.println("input corresponding number");
int number0 = input.nextInt();

}


I'm trying to learn a little more about for loops and I can't seem to figure out how to do this without having to put all the data in an array. I'd prefer not to do that if possible. I figured there has to be a way to either tell the data to be stored into another variable or increment the variable name for every iteration. any ideas?