Back to all lessons


Lesson 12

Recursion, arrays

Task 1

Read the snippet


public class Main {
    public static void main(String[] args) {
        int[][] multi = new int[5][10];

        for (int i = 0; i < multi.length; i++) {
            System.out.println("Row #"+i);
            for (int j = 0; j < multi[i].length; j++) {
                System.out.println("[" + j + "]: " + multi[i][j]);
            }
        }
    }
}
        
Task 2

Create 2-dimensional array, populate with random data and display in any form (another that showed at Task 1).

Task 3

Print diagonals of array from Task 2.

Task 4

Create Pascal's triangle using 2-dimensional array.

Task 5

Multiply two 2-dimensional arrays by each other. In math it is called "matrix multiplication" (matrix = 2d array). This video should help: https://youtu.be/OMA2Mwo0aZg