indexoutofboundsexception - Stars.java arrayindexoutofbounds -
I am trying to understand why I have received this error for about 3 hours and I have some help to get it Before my computer pays the price.
I am getting this error } The file type is being written in the following such as Number of lines and number of lines per row is not known for each line And the file is read through the command line with the main program. / P> == array.length instead of array.length-1 , because
import java.io.buffferedReader; Import java.io.fileReader; Import java.io.IOException; Import java.util. *; Public category stars table {Private Archieist & Lt; Integer & gt; A = New Arrestist & lt; Integer & gt; (); Private string title; Private string readLine = null; Private int rows = 0; Private integer array [] []; Public Stars Table (String Filename) {try {BufferedReader br = new BufferedReader (New FileReader (fileName)); Title = br.readLine (); While ((readLine = br.readline ()) = Faucet {System.out.println (readLine); AddArray (ReadLine); Rows ++; } Br.close (); } Hold (IOException e) {System.err.println ("File not found" "Enter the file name in the command line."); System.exit (1); }} Public String Title () {Return Title; } Public Zero addArray (string readline) {int i = 0; String [] splitLine = readLine.split ("\\ s +"); (I = 0; i & lt; splitLine.length; i ++) for {a.add (integer.valof (splitline) .tim ())); }} Public integer [] [] getArray () {toArray (); Return array; } Public zero toArray () {array = new integer [rows] [a.size () / rows]; int g = 0; {System.out.println () for (Int i = 0; I
Headline Line 0 0 0 1 1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3
array.length is greater than the largest index. It can also be applied to
a.size () , not sure.
Comments
Post a Comment