I have an array:
char[] modifiers = {'A', 'M', 'D'};
and a variable:
char a = 'D'
How to get position of variable value in array?
Thanks
This is very simple and tested code for your reference
String[] arrayValue = {"test","test1","test2"};
int position = Arrays.asList(arrayValue).indexOf("test");
position: 0th Position
This is the shortest way I know. I had this as a comment but now writing it as an answer. Cheers!
Character[] array = {'A','B','D'};
Arrays.asList(array).indexOf('D');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With