Is it possible to refer to a variable by appending variations?

cleakeneespip

New Member
I would like to refer to a variable whose name has a number in a System.out.print() method.\[code\]public class Loopname{public static void main (String [] args){ int num= 1;String file1= "Hello";System.out.print("file"+num); }}\[/code\]When this simple code is run, I receive "file1". This is completely understandable, but I would like to retrieve the value of it. I am doing this because I would like to call a series of these files without calling them individually in the print method. Conceptual code:\[code\] public class Loopname{ public static void main (String [] args){ String file1= "Hello"; String file2= "Hola"; String file3= "Bonjour"; for (int i=1; i<=3;i++){ System.out.println("file"+i); } } }\[/code\]I am quite a newbie. Please help me if you can. I am open to any advice and simpler versions of code. Thanks in advance!I would like the user to see: \[code\]HelloHolaBonjour\[/code\]
 
Back
Top