LEC : 15 | JAVA

        

LEC:15

Multidimensional Arrays in JAVA



Source Code:

package lec_5;

import java.util.*;

public class Lec_5 {

    public static void main(String[] args) {
//     Multidimensional arrays
//        columns >3
//    1   2   4         rows >3
//    6   8   99        rows 
//    99 66 88          rows 

        int array[][] = {
            {1,2,4,66},  //row 1
            {6,8,99,46},//row 2
            {99,66,88,46},//row 3
            {90,61,68,54},//row 4
            {999,6,18,1}//row 5
        };
        
        //using for loop to print out the results
        for(int i=0;i<5;i++) // Loop for the rows 
        {
            for(int j=0;j<4;j++) //Loop  for the columns
            {
                System.out.print(array[i][j]+"\t");
            }
              System.out.println("");
        }
    }

}


Comments

Popular posts from this blog

RunwayWithCode

web development Lectures

C++ Lectures