Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

ArrayIndexOutOfBoundException...!(having problem in inserting values in 2D array for matrix)

2694075Jun 14 2014 — edited Jun 15 2014

public class matrix_mul

{

  static int a[][],b[][],k;

  public static void main(String o[])

  {

       k=0;

       a=new int[3][3];

       b=new int[3][3];

       for(int i=0;i<3;i++)

       {

            for(int j=0;j<3;i++)

            {

                 a[i][j]=Integer.parseInt(o[k++]);

            }

           

       }

       for(int i=0;i<3;i++)

       {

            for(int j=0;j<3;i++)

            {

                 b[i][j]=Integer.parseInt(o[k++]);

            }

           

       }

       for(int i=0;i<3;i++)

       {

       for(int j=0;j<3;i++)

            {

            System.out.println(a[i][j]);

            }

           

       }

       for(int i=0;i<3;i++)

       {

            for(int j=0;j<3;i++)

            {

                 System.out.println(b[i][j]);

            }

           

       }

     }

}


well, this is my code for inserting values in 2D array for matrix & then printing it on Command line

   but it's show AraayIndexOutOfBoundExcepton 3 or sometimes 1 (on cmd)
  i m new to this language so plz help

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 13 2014
Added on Jun 14 2014
1 comment
1,057 views