public static int getIndex(String value, Constants type) {
int myPosition = -1;
for (int i = 0; i < type.length; i++) {
if (type[i] == value) {
myPosition = i;
break;
}
}
return myPosition;
}
I was thinking of a generic method where i pass the value and Constants into the method to get the required index of the string value. Its pretty much easy to do in JS
, but i am not sure how can i toss a method of same in java.
CommonMethods.Utils.getIndex("Kevin", Contants.Name);
The above method is not working, as it says "length cannot be resolved or is not a field"