-1
String[] prompts = {"Describe to me in a sentence why this is a cool program.", 
                    "Describe to me in a sentence how your day was.", 
                    "Describe to me in a sentence what programming means to you.", 
                    "Describe to me in a sentence why food is neccessary for humans."};
System.out.println(prompts);

I want to call a random string from the array how should I report it?

jrbedard
  • 3,494
  • 5
  • 27
  • 34

1 Answers1

2

Just need to randomly generate an index in the range of your array length

int i = new Random().nextInt(prompts.length);
System.out.println(prompts[i]);
yiwei
  • 3,692
  • 9
  • 33
  • 53