Back to all lessons


Lesson 13

Points

Task (2 points)

Create methods:

  • sumOfElementsOnDiagonals: sums all numbers from diagonals
  • printBordersOf: displays all values located on edges

        public class HintClass {
            public static void main(String[] args) {
        
                int[][] diagArr = {
                    {1,  2,  3,  4},
                    {5,  6,  7,  8},
                    {9,  10, 11, 12},
                    {13, 14, 15, 16}
                };
        
                printBordersOf(diagArr);
        
                System.out.println(
                    sumOfElementsOnDiagonals(diagArr)
                );
        
            }
        
            // tip: start here
        
        }