K
K
Koshkasobaka2020-10-29 22:10:39
Java
Koshkasobaka, 2020-10-29 22:10:39

Java. How to check if a 2D array is square?

Hello, a two-dimensional array is passed to the method, I need to check if it is square. I can't think of anything, please help

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Roo, 2020-10-29
@Koshkasobaka

You need to check that all arrays have the same size.

O
Orkhan, 2020-10-29
Hasanly @azerphoenix

If I understand the problem correctly, then:

if(array1.length == array2.length) {
System.out.println("Двумерный массив является квадратным");
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question