View Single Post
  #1 (permalink)  
Old 07-31-2007, 11:40 PM
fernando fernando is offline
Member
 
Join Date: Jul 2007
Posts: 40
fernando is on a distinguished road
Error: java.lang.ArrayIndexOutOfBoundsException
Hi, I want to make a multiplication table where the user can choose how many rows and columns the table has, i get a "java.lang.ArrayIndexOutOfBoundsException: 5
at Review.main(Review.java:26)" error...I don't get that, anyone got any ideas? anyways here's my code take a look

Code:
// The "Review" class. import java.awt.*; import hsa.Console; public class Review { static Console c; // The output console public static void main (String[] args) { c = new Console (); int a, b; c.print ("a/row:"); a = c.readInt (); c.print ("b/col:"); b = c.readInt (); int table[] [] = new int [a] [b]; // max for table for (int row = 1 ; row <= a ; row++) //length of rows { for (int col = 1 ; col <= b ; col++) //length of columns { table [row] [col] = row * col; c.print (table [row] [col] + " "); } c.println (); } } // main method } // Review class
Thanks.
Reply With Quote
Sponsored Links