Assume you are given a boolean variable named isSquare and a 2-dimensional array that has has been created and assigned to a2d. Write some statements that assign true to isSquare if the entire 2-dimensional array is square meaning every row and column has the same number of elements as every other row and column.

LANGUAGE: JAVA

CHALLENGE:

Assume you are given a boolean variable named isSquare and a 2-dimensional array that has has been created and assigned to a2d. Write some statements that assign true to isSquare if the entire 2-dimensional array is square meaning every row and column has the same number of elements as every other row and column.

SOLUTION:

The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,

1 Comment

  1. Spencer on November 9, 2016 at 2:48 pm

    isSquare = true ;

    for (int i = 0 ; i < a2d.length; i++ ) {
    if (a2d.length != a2d[i].length ) {isSquare = false ;}
    }

Leave a Comment

You must be logged in to post a comment.