Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: I have to send this tomorrow again and i don't have any idea what's wrong

  1. #1
    Junior Member
    Join Date
    Apr 2022
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I have to send this tomorrow again and i don't have any idea what's wrong

    class App2 { 
     
        public static void main (String args[]){
     
        final int a=5;
        final int b=3;
     
        int[][] Table= new int[a][b];
     
        Table[0][0]=182;
        Table[0][1]=41;
        Table[0][2]=202;
     
        Table[1][0]=145;
        Table[1][1]=85;
        Table[1][2]=325;
     
        Table[2][0]=195;
        Table[2][1]=15;
        Table[2][2]=115;
     
        Table[3][0]=110;
        Table[3][1]=24;
        Table[3][2]=407;
     
        Table[4][0]=255;
        Table[4][1]=11;
        Table[4][2]=357;
     
        for(int i=0;i<=a;i++){
            System.out.println();
            for(int j=0;j<=b;j++){
                System.out.print(Table[i][j]+" ");
            }
        }
     
     
        }
    }
    This is the error i get from visual studio and cmd

    182 41 202 Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 3 out of bounds for length 3
    at App2.main(staf.java:33)

    I searched a bit and it seems like there is something wrong with my brackets on the array but i can't find how to fix it

  2. #2
    Member
    Join Date
    Apr 2022
    Posts
    36
    Thanks
    0
    Thanked 8 Times in 8 Posts

    Default Re: I have to send this tomorrow again and i don't have any idea what's wrong

    remove = in the for

  3. #3
    Junior Member
    Join Date
    Apr 2022
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I have to send this tomorrow again and i don't have any idea what's wrong

    I have already tried it, it doesn't seem to be the problem.

  4. #4
    Member
    Join Date
    Apr 2022
    Posts
    36
    Thanks
    0
    Thanked 8 Times in 8 Posts

    Default Re: I have to send this tomorrow again and i don't have any idea what's wrong

    from both for you have to remove it

  5. #5
    Junior Member
    Join Date
    Apr 2022
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I have to send this tomorrow again and i don't have any idea what's wrong

    Yeah i did it for both and its still the same.

  6. #6
    Member
    Join Date
    Apr 2022
    Posts
    36
    Thanks
    0
    Thanked 8 Times in 8 Posts

    Default Re: I have to send this tomorrow again and i don't have any idea what's wrong

        final int a=5;
        final int b=3;
     
        int[][] Table= new int[a][b];
     
        Table[0][0]=182;
        Table[0][1]=41;
        Table[0][2]=202;
     
        Table[1][0]=145;
        Table[1][1]=85;
        Table[1][2]=325;
     
        Table[2][0]=195;
        Table[2][1]=15;
        Table[2][2]=115;
     
        Table[3][0]=110;
        Table[3][1]=24;
        Table[3][2]=407;
     
        Table[4][0]=255;
        Table[4][1]=11;
        Table[4][2]=357;
     
        for(int i=0;i<a;i++){
            System.out.println(Arrays.toString(Table[i]));
        }

Similar Threads

  1. I have to send this tomorrow and i have now idea what is wrong
    By stathisxm in forum What's Wrong With My Code?
    Replies: 13
    Last Post: April 7th, 2022, 07:14 AM
  2. no idea what is wrong with this code
    By MLG_C00K1E in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 23rd, 2017, 10:15 AM
  3. [SOLVED] Boolean trouble, no idea whats wrong.
    By Cekeh in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 20th, 2013, 07:13 PM
  4. Help! have no idea what's wrong with my code..
    By Zaki in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 17th, 2012, 10:22 PM
  5. Replies: 2
    Last Post: September 2nd, 2012, 02:06 PM