I'm trying to get my string array to get a random string from it and if it is a certain string then it needs to print an outcome in my text area.
String[] items = new String[]{"nothing useful", "trash", "a fork"};
Said array.
Random rand = new Random();
String outcome = items[rand.nextInt(items.length)];
getting a random string from the array as a string named outcome.
if(outcome.equals(items[2])){
textArea2.append("a fork" + "\n");
}
my attempt at getting it to put a "a fork" in a text area. All of my text areas work so that's not my problem.
I've tried to use .equals, ==, if(outcome=="a fork"), and various things like that without any of them working.
I need it to add 'a fork" to the text area named textArea2.
Aucun commentaire:
Enregistrer un commentaire