0
String[][] work = new String[3][];

thats work

    work[0] = new String[3];
    work[0][0]=" !!! ";
    work[0][1]=" !!! ";
    work[0][2]=" !!! ";
    work[1] = new String[3];
    work[1][0]=" !!! ";
    work[1][1]=" !!! ";
    work[1][2]=" !!! ";
    work[2] = new String[3];
    work[2][0]=" !!! ";
    work[2][1]=" !!! ";
    work[2][2]=" !!! ";

thats dont work for me i dont know where is mistake Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 3

for(int i=0;i<13;i++){
            work[i]= new String[3];
        }
        for(int i=0;i<13;i++){
            for(int j=0;j<3;j++){
                work[i][j]=" !!! ";
            }
        }
        for(String[] x: work){
            for(String e : x){
                System.out.println(e);
            }System.out.println();
        }

mistake is here String[][] work = new String[13][]; 3->13

1 Answer 1

1

You should change

for(int i=0;i<13;i++) {

to

for(int i=0;i<work.length;i++) {

This will save you from similar typos.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.