I have a String array:
String [] array={"1","2","3","4","5","6","7","8","9"};
Which I convert into an array list:
 ArrayList<String> al = new ArrayList<String>(Arrays.asList(array));
I want to get a random value from my ArrayList.
I have a String array:
String [] array={"1","2","3","4","5","6","7","8","9"};
Which I convert into an array list:
 ArrayList<String> al = new ArrayList<String>(Arrays.asList(array));
I want to get a random value from my ArrayList.
 
    
     
    
    Use Random class to do that, argument of method nextInt is the bound on the random number to be returned. It must be positive:
Random random = new Random();
yourList.get(random.nextInt(yourList.size()));
 
    
    myList.random()
random() is a default extension function included in base Kotlin on the Collection object.
