Hi again. (I am running up against a deadline.) I get an error in defining this array of rectangles. The definition compiles but each cell of the array errors: "']' expected rect [0] = new Rectangle (0, 0, 100, 100);" The error looks like:
Rectangle [] rect = new Rectangle [9]; rect [0] = new Rectangle (0, 0, 100, 100); // a0 rect [1] = new Rectangle (100, 0, 100, 100); // a1 rect [2] = new Rectangle (200, 0, 100, 100); // a2 rect [3] = new Rectangle (0, 100, 100, 100); // b0 rect [4] = new Rectangle (100, 100, 100, 100); // b1 rect [5] = new Rectangle (200, 100, 100, 100); // b2 rect [6] = new Rectangle (0, 200, 100, 100); // c0 rect [7] = new Rectangle (100, 100, 100, 100); // c1 rect [8] = new Rectangle (200, 200, 100, 100); // c2 Where am I wrong??
Capp, You are simply using the wrong syntax. To define an array in the place you have chosen to (i.e. in some free floating initialisation at the top of the class definition) you must do it like this - String [] strArr = {"this", "is", "four", "Strings"}; which creates an array of 4 String objects. So for your example you must use -
Alternatively you can code it the way you have chosen to but it should be within a method. The syntax you are using "rect[n] = new Rectangle(i,j,k,l);" will work within a method. Try moving it inside the init() method and see.
[This message has been edited by Cindy Glass (edited October 09, 2001).]