Matlab has this function called ismember(n,P)
that allows us to check if the number n
is in the matrix P
. If n
is in P
it returns 1, otherwise 0. My question is, is there anything similar in Java that would allow me to check the above.
Thanks in advance
Asked
Active
Viewed 42 times
0

Tony Tannous
- 14,154
- 10
- 50
- 86

Shahzeb R. Noureen
- 63
- 11
-
Does java have matices? – tkausl Jun 14 '17 at 19:59
-
Is there a reason why writing a simple loop and comparing each element is not good enough? You should show what you've tried and why it didn't work. – Justin Jun 14 '17 at 20:04
-
Possible duplicate?: [How can I test if an array contains a certain value?](https://stackoverflow.com/q/1128723/52738) – gnovice Jun 14 '17 at 20:05
-
@tkausl Correct me if I am wrong but is this not a matrix in Java? `int[][] scores = {{1,2,3},{6,7,8},{2,0,5}};` – Shahzeb R. Noureen Jun 23 '17 at 22:32
-
@Justin Thanks, I wrote a loop as you suggested and it worked but just wanted to see if there was an even quicker way of checking – Shahzeb R. Noureen Jun 23 '17 at 22:44