1 Reply Latest reply: Jun 15, 2014 4:10 PM by rp0428 RSS

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

    bb9b0e9d-8742-4d4f-ae50-cc0653349f1b

      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