luk luk - 5 months ago 22
Java Question

Search for a value in a two dimensional array

I want to compare a number to a dimensional array. I think that my problem is here, but I dont know why it cannot compile because of this.


enter image description here

Answer Source

That's because a[j][i] is int and no Integer, it means that you can't compare it with .equals() since it is a primitive type, you have to use ==

Furthermore, you are comparing a[j] with an int but a[j] is an array, you have to access its int with double [][] : a[i][j]

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download