Hi guys im facing with an problem with Matrixes.
Actually what im facing is how to check whether the matrix is diagonal or not
ex: 100
010
001
this is an diagonal matrix.
So my code is like below:
<public boolean isDiagonal() {
int i,j;
for(i=0;i<rows;i++)
{
for(j=0;j<columns;j++)
{
if( (this.checkNull((E) this.vals[i][j]) == false) && (i!=j)){
return false;
}
}
}
return true;
}
private boolean checkNull(E elem){
boolean z = false;
if(( elem.toString().equals("0") ) || (elem.toString().equals("false") ))
{
z = true;
}
return z;
}
>
Can u please explain me a bit about this where i did mistake or if anybody know any better solution please show me.

