Addressing an Array which doesn't exist until a loop runs?
HI,
I'm trying to address an array which is created by a loop. But as its name doesn't yet exist I can't compile it.
My code
{
BufferedReader into=new BufferedReader(new FileReader(args[0]));
while ((thisLine = into.readLine()) !=null )
{
fileloc = thisLine.split (",");
filelist.add(fileloc[1]);
ArrayList<String> arrayname =new ArrayList<String>();
String arraynamer = ("array"+fileloc[0]) ;
FileReaderfile =new FileReader(fileloc[1]);
BufferedReader in=new BufferedReader(file);
StreamTokenizer st=new StreamTokenizer(in);
ArrayList<String> temparray =new ArrayList<String>();
while ((tokval = st.nextToken()) != StreamTokenizer.TT_EOF)
{
switch (tokval)
{
case StreamTokenizer.TT_WORD:
temparray.add(st.sval);
break;
case StreamTokenizer.TT_NUMBER:
String number2 = Double.toString(st.nval);
temparray.add(number2);
break;
default:
break;
}
}
ArrayList $arraynamer = (ArrayList)temparray.clone();
}
}
The file its assessing is laid out like
0, c:\filepath
1, c:\otherfilepath
For each of the lines isted in the file it should creates a new array called whatever is before the "," array0, array1 etc
Now I can access the data using $arraynamer, providing I'm in the loop, but I can't access array0 at all because it doesn't exist until the program runs.
So for example if I add in
System.out.println("HI:"+array0.get(1);
I get
arraypopulator.java:78: cannot find symbol
symbol : variable $array0
location: class arraypopulator
System.out.println("TRIAL1:"+$array0.get(1));
^
1 error
I have tried with/without the $.

