Reputation: 127
So I have a text file reader that reads in each string as they come in.
String R1Name = fileScanner.nextLine();
String R1URL = fileScanner.nextLine();
String R2 = fileScanner.nextLine();
String R2Name = fileScanner.nextLine();
String R2URL = fileScanner.nextLine();
String R3 = fileScanner.nextLine();
String R3Name = fileScanner.nextLine();
String R3URL = fileScanner.nextLine();
Etc.
How can I have it so it creates a simple for loop with number 1-7 that does the same thing with less code?
for(int i=0; i<8; i++){
String R(i) = fileScanner.nextLine();
String R(i)URL=fileScanner.nextLine();
}
Trying to get something like this but with no luck
Upvotes: 0
Views: 2093