I have a project i am a beginner in java and I am stuck and would appreciate any help. my output is as follows..........
output:
Lisa Fowler
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at PassingArrays.main(PassingArrays.java:21)
I am importing a list of 25 name from a text file and the above output I am receiving, should be 25 names. I also have to put a double tab delimeter in between the names when I output them to the screen. I hope someone can help me finish this, Thanks
output:
Lisa Fowler
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at PassingArrays.main(PassingArrays.java:21)
I am importing a list of 25 name from a text file and the above output I am receiving, should be 25 names. I also have to put a double tab delimeter in between the names when I output them to the screen. I hope someone can help me finish this, Thanks
import java.io.*;
import java.util.*;
public class PassingArrays {
public static void main(String[] args) throws IOException {
String thisLine;
String[] temp;
String delimiter="\t\t";
String [][] myArray = new String[24][24];
BufferedReader br= new BufferedReader(new FileReader("C:/Users/dstevens/Desktop/names.txt"));
while ((thisLine = br.readLine()) != null)
{
for (int j=0; j<25; j++) {
thisLine=br.readLine();
temp = thisLine.split(delimiter);
for (int i = 0; i < 25; i++) {
myArray[j][i]=temp[i];
System.out.println(myArray[j][i]);
// System.out.println(temp);
// System.out.println(temp[i]);
}
}
}
}
}