@Override 
  public boolean equals(Object obj)
  { if(obj instanceof Matrix)
    { Matrix that=(Matrix)obj;
      if(this.matrix.length!=that.matrix.length || this.matrix[0].length!=that.matrix[0].length)
      { return false;
      }    
      else
      { for(int i=0;i<this.matrix.length;i++)
        { for(int j=0;j<this.matrix[0].length;j++)
          { if(!this.matrix[i][j].equals(that.matrix[i][j]))
            { return false;
            } 
          }
        } 
        return true;
      }    
    }
    else
    { throw new RuntimeException(obj+" is not a Matrix.");
    }
  }