Page 315 - Cs_withBlue_J_C11_Flipbook
P. 315

27              for (i=0; i<5; i++)
                   28              {

                   29                  ar3[j++]=ar2[i];
                   30              }

                   31              //Displaying the 3rd array
                   32              System.out.print("Merged Array is: ");

                   33              for (i=0; i<10; i++)
                   34              {
                   35                  System.out.print(ar3[i]+ " : " );

                   36              }

                   37          }
                   38      }

                 The output of the preceding program is as follows:
                 Enter element in 1st array: 23
                 Enter element in 1st array: 36
                 Enter element in 1st array: 31
                 Enter element in 1st array: 0
                 Enter element in 1st array: 2
                 Enter element in 2nd array: 25
                 Enter element in 2nd array: 36
                 Enter element in 2nd array: 32
                 Enter element in 2nd array: 31
                 Enter element in 2nd array: 25
                 Merged Array is: 23 : 36 : 31 : 0 : 2 : 25 : 36 : 32 : 31 : 25 :


                     11.8 DOUBLE-DIMENSIONAL ARRAY
                 A double-dimensional array or 2D array is a type of array which is used when we need to refer to data, stored in a
                 tabular form. In this tabular format, data are stored in horizontal and vertical form and are known as rows and columns
                 respectively.

                                                                                                 st
                 So, a double-dimensional array uses a combination of rows and columns, where the 1  index refers to the row
                                 nd
                 position and the 2  index refers to the column position. It is also known as the double subscripted value as it has
                 2 subscripts.
                 Let us understand this concept with the following example.

                                                               C O L U M N

                                                               0    1     2    3    4
                                                    R    0
                                                    O    1               44

                                                   W     2
                                                         3          67


                                                                                                                       313
                                                                                                              Arrays   313
   310   311   312   313   314   315   316   317   318   319   320