mercredi 18 mai 2022

How to generate random value from enum and put it in array?

I got an enum which is filled with "items" and I want to generate one random item of the enum and put it into my inventory, which I made out of an array. The array only has room for 10 ints.

public class InventoryEnums {
    public static void main (String[] args){

    int[] inventar = new int[9] // int array mit 10 Plätzen

    enum items {
        KARTE, MONSTERBALL, MONSTERDEX, FAHRRAD, VM03, HYPERHEILER, AMRENABEERE, TOPGENESUNG, ANGEL, TOPSCHUTZ
    }



Aucun commentaire:

Enregistrer un commentaire