check if every cell is identical
if ( arr [ i ] [ j ] != arr [ k ] [ j ] ) { horizontal = false ; break ; } } } if ( ! horizontal && ! vertical ) System . out . println ( " NO " ) ; else if ( horizontal && ! vertical ) System . out . println ( " HORIZONTAL " ) ; else if ( vertical && ! horizontal ) System . out . println ( " VERTICAL " ) ; else System . out . println ( " BOTH " ) ; }