Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

keep getting error on array 2d list, please help deadline tuesday

$
0
0
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

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]);
	        	        }  
	        	       }  
	        	     }  
	        	    
	        	   }  
}

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>