I have a string array:
String[] fruits = {"Apple","Mango","Peach","Banana","Orange","Grapes","Watermelon","Tomato"};
and I get a random element from this:
String random = (fruits[new Random().nextInt(fruits.length)]);
now I want to get the number in which the apple is present, when I press the button to get random fruits, for example, when I press the randon button, it gives me a Banana..and should also give me this element number 3
I get the item, but have a problem getting the item number, so please help me
java android string arrays random
user1817558 Nov 12 2018-12-12T00: 00Z
source share