Hi I'm doing a project in java.It is the game othello.It was all going well till i got an ArrayOutOfBoundsException. the array is this buttons[9][9]; If you dont know othello it's a board game with an 8x8 board.

The Exact error is "ArrayOutOfBoundsException: 9" and give the lines which the error is which are:

1->

if (the_buttons[rows][colunm+1].getIcon().equals(BG)== true &&
                  the_buttons[rows+1][colunm].getIcon().equals(BG)== true &&
	  the_buttons[rows][colunm-1].getIcon().equals(BG)== true && 
	  the_buttons[rows-1][colunm].getIcon().equals(BG)== true )
	       {
		dialog(2);
		return false;
	        }		 
    return true;

2->

if(checkIfOccupied() == false && checkForSq()== true )
		   {
		          if(checkIflegal()==true)
		            {
			 if (checkWhichPlayer()==true)
          			     { 							                          the_buttons[rows][colunm].setIcon(r);
				 checkForward(r,Y)  ;
				 checkUpLeft(r,Y)   ;
				 checkUpRight(r,Y)  ;
			            	 checkBackwards(r,Y);
			            	 checkDownLeft(r,Y) ;
			             	 checkDownRight(r,Y);
			             	 checkDown(r,Y)     ;
			                 checkUp(r,Y)       ;
	   		     }

3->

if (cmd.equals(""+i))
	    {
	              checkforColunm(j=0,i);
	             PickButton(rows,colunm);
                            
                      }

CAN ANYONE HELP IT'S THE LAST HURDEL AND THIS NEEDS TO BE IN TOMORROW.....

you are exceeding the array's bounds.
exactly, one can't figure out what causes the error, because the manipulation is done by
your code that comes before these blocks.
check it again, either you go beyond index 8 or below index 0, good luck.

I'm Sorry to do this but I really need help with this I'm posting my project so far to see if you can help

You just forgot to mention that beside that you getting another 30 errors, not nice of you...

--------------------Configuration: <Default>--------------------
C:\Downloads\othello.java:692: illegal start of type
        else if (checkWhichPlayer()==false)
        ^
C:\Downloads\othello.java:692: ';' expected
        else if (checkWhichPlayer()==false)
            ^
C:\Downloads\othello.java:692: illegal start of type
        else if (checkWhichPlayer()==false)
                ^
C:\Downloads\othello.java:692: ';' expected
        else if (checkWhichPlayer()==false)
                                   ^
C:\Downloads\othello.java:731: illegal start of type
        return true;       
        ^
C:\Downloads\othello.java:731: ';' expected
        return true;       
              ^
C:\Downloads\othello.java:734: class, interface, or enum expected
public boolean checkForSq()
       ^
C:\Downloads\othello.java:742: class, interface, or enum expected
                    return false;
                    ^
C:\Downloads\othello.java:743: class, interface, or enum expected
                 }       
                 ^
C:\Downloads\othello.java:745: class, interface, or enum expected
       }
       ^
C:\Downloads\othello.java:747: class, interface, or enum expected
public void checkForWin() 
       ^
C:\Downloads\othello.java:750: class, interface, or enum expected
            for ( i=0 ;i < 64 ;i++ )
                       ^
C:\Downloads\othello.java:750: class, interface, or enum expected
            for ( i=0 ;i < 64 ;i++ )
                               ^
C:\Downloads\othello.java:755: class, interface, or enum expected
                }
                ^
C:\Downloads\othello.java:759: class, interface, or enum expected
                }
                ^
C:\Downloads\othello.java:763: class, interface, or enum expected
            if(redButtons < YellowButtons)
            ^
C:\Downloads\othello.java:766: class, interface, or enum expected
    }
    ^
C:\Downloads\othello.java:775: class, interface, or enum expected
                 if (i == 2 )
                 ^
C:\Downloads\othello.java:777: class, interface, or enum expected
                 if (i == 3 )
                 ^
C:\Downloads\othello.java:779: class, interface, or enum expected
                 if (i == 4 )
                 ^
C:\Downloads\othello.java:781: class, interface, or enum expected
                 if (i == 5 )
                 ^
C:\Downloads\othello.java:784: class, interface, or enum expected
    }
    ^
C:\Downloads\othello.java:788: class, interface, or enum expected
public static void main(String args[]) {
              ^
C:\Downloads\othello.java:790: class, interface, or enum expected
        frame.setSize(330,300);
        ^
C:\Downloads\othello.java:791: class, interface, or enum expected
        frame.setTitle("Othello");
        ^
C:\Downloads\othello.java:793: class, interface, or enum expected
        frame.setVisible(true);
        ^
C:\Downloads\othello.java:794: class, interface, or enum expected
        frame.addWindowListener(new WindowAdapter() {
        ^
C:\Downloads\othello.java:795: class, interface, or enum expected
            public void windowClosing(WindowEvent e) {
                   ^
C:\Downloads\othello.java:797: class, interface, or enum expected
            }
            ^
C:\Downloads\othello.java:799: class, interface, or enum expected
    }
    ^
30 errors

Process completed.

I'm very sorry about that this one has no errors I just complied it

did u face null pointer exception?!
u have more than one problem i guess!

no I'm trying to fix that too It's late and I just cant think.Any suggestions on either problems?

take this file, i added this line to help you,
System.out.println("This"+rows+" "+colunm); line number 730

look at the printed values, you are exceeding 9.

I know in the_buttons[2][8],[3][8],[4][8] the lines also says that the rows are -1 so [4][8] say's it's [3][8]. but I cant find why this is happening the same with the exceeding the array I tried changing the array to [8][8] but it doesn't work. I know it's something small and right in front of me i just cant see it.

line 731, adding 1 to colunm 8 makes it 9, which exceeds the array,,

Ya that seemed to work for a few buttons I'll try go through the rest Cause I need this in early tomorrow.Any suggestions on the Null pointer?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.