An enum should be named in the singular, and should start with an uppercase letter.
enum Item { KARTE, MONSTERBALL, MONSTERDEX, FAHRRAD, VM03, HYPERHEILER, AMRENABEERE, TOPGENESUNG, ANGEL, TOPSCHUTZ }
And I suggest you work at devising a more descriptive name than “Item”.
Get an array of all the enum objects by calling values.
Item[] allItems = Item.values() ;
Generate a random number. Use that number as the index into your array of all items.
int randomIndex = ThreadLocalRandom.current().nextInt( 0 , allItems.length ) ; // ( inclusive , exclusive )
Item rando = allItems[ randomIndex ] ;
Or perhaps you meant to randomly sort (shuffle) all the elements of the enum. If so, make a List backed by the array. Call Collections.shuffle. Changes made to the list also affect the backing array. So the array is shuffled.
Item[] allItems = Item.values() ;
List< Item > list = Arrays.asList( allItems );
Collections.shuffle( list );
More briefly:
Item[] allItems = Item.values() ;
Collections.shuffle( Arrays.asList( allItems ) );
See this code run live at Ideone.com.
[MONSTERBALL, TOPSCHUTZ, KARTE, FAHRRAD, VM03, MONSTERDEX, ANGEL, AMRENABEERE, TOPGENESUNG, HYPERHEILER]
items.values(). Note:int[9]has room for only 9 int's!new int[9]will generate an array with ten elements? When you pass a size of nine, you get an array of nine. It’s as simple as that. And when you want to store elements of typeItems, you need anItems[]array, not anint[]array.