I'm sort of new to programming and I may be trying to run before i can walk but basically I have a list of strings and at the end of each printed line I'd like to randomly select one of the strings. I did this and it did pick a random string but the problem is every time it's used in the program it sticks to that one random string.
String items[] = {"bla bla", "asdnoaisd", "anafgsfsan"};
int amount;
String list;
Random r = new Random();
amount = (int) (Math.random()*25+1);
list = items[r.nextInt(12)];
help would be appreciated
UPDATE - so I probably worded this wrong. the problem isn't getting a random string but I need it to reset after every time it's used, so after it's used once it should reset and pick another string from the list.
Aucun commentaire:
Enregistrer un commentaire