How to generate a random number from an array? not out of range.
int n [] = {1,7,3,5,8,10,33,12,18}
import java.util.Random; ... Random random = new Random(); System.out.println(n[random.nextInt(n.length)]);
In the general case, get a random integer from the minimum value of 0 to the maximum length of the array -1 and use it as the index of the array.
Source: https://habr.com/ru/post/1738740/More articles:xpath / xslt to determine the node context index relative to all nodes with the same name? - xmlhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1738736/any-tool-to-convert-bulk-php-files-to-utf-8-without-bom&usg=ALkJrhitANa84saBh6Wf8Q590-BeoCf9rgRails - number of lines in a file - fileОбщая архитектура CMS - web-applicationsAndroid Extend BaseExpandableListAdapter - androidASP.NET MVC 2 RTM - icon does not appear in Internet Explorer - htmlInsert the infront character of each word into a string using C ++ - c ++Forcing www prefix to PHP / htaccess / mod_rewrite - phpcalling WinForms programs contextmenustrip - c #Call the named routes in CakePHP in the same way as in Ruby on Rails - ruby-on-railsAll Articles