#### Aman

##### Headphoneus Supremus

- Joined
- May 12, 2004

- Posts
- 4,475

- Likes
- 14

The code is simply a fill image program. It draws a triangle and a square, and it simply changes the "*" symbols to "." symbols within the image's array. It's really just an 'example' of how it could be done. It's a long story.

Code:

Code:

`[left]public class image{ public static int i; //y public static int k; //x public static String array[][] = new String[10][20]; public static void drawImage(){ for (i = 0; i < 20; i++){ for(k = 0; k < 10; k++){ array[k][i] = "*"; } } //^Makes entire image filled with "*" array[0][0] = "*"; array[1][0] = "-"; array[2][0] = "|"; array[3][0] = "|"; array[4][0] = "|"; array[5][0] = "|"; array[6][0] = "|"; array[7][0] = "|"; array[8][0] = "-"; array[9][0] = "*"; //^One collumn of square for(k = 0; k < 10; k++){ array[k][19] = array[k][0]; } //^Makes second collumn of square array[1][0] = "*"; array[1][2] = "-"; array[1][3] = "-"; array[1][4] = "-"; array[1][5] = "-"; array[1][6] = "-"; array[1][7] = "-"; array[1][8] = "-"; array[1][9] = "-"; array[1][10] = "-"; array[1][11] = "-"; array[1][12] = "-"; array[1][13] = "-"; array[1][14] = "-"; array[1][15] = "-"; array[1][16] = "-"; array[1][17] = "-"; array[1][18] = "-"; array[1][19] = "*"; //^Makes first line in square for(i = 0; i < 20; i++){ array[9][i] = array[1][i]; } //^Makes second line in square array[4][8] = "/"; array[4][9] = "\\"; array[5][7] = "/"; array[5][10] = "\\"; array[6][6] = "/"; array[6][11] = "\\"; array[7][5] = "/"; array[7][12] = "\\"; array[8][4] = "-"; array[8][5] = "-"; array[8][6] = "-"; array[8][7] = "-"; array[8][8] = "-"; array[8][9] = "-"; array[8][10] = "-"; array[8][11] = "-"; array[8][12] = "-"; //^Triangle for(k = 0; k < 10; k++){ for(i = 0; i < 20; i++){ System.out.print(array[k][i]); if(i == 19){ System.out.println(" "); } } } //^Draws square and rectangle fillImage(k, i); } public static void fillImage(int k, int i){ if(array[k][i] == "*"){ array[k][i] = "."; } //^Makes each asterix (*) a period (.) k++; i++; if(k > 9 || i > 19){ drawImage(); fillImage(k, i); } //^Call itself using recursion until maximum array values are hit public static void main (String [] args){ drawImage(); } }[/left]`

When I go to compile this code, it works just fine. When I run it, it draws the square and circle, but it gives me an "ArrayBoundsException error (10)". I tried a wide assortment of fixes but I get furthest into the program by using the code above. If anybody could help me in finding out what exactly I could do to fix this error, it would mean the world to me. It's very important that I get this done for tomorrow.

Thanks in advance for any help!!