vendredi 19 janvier 2018

how to use scanner.in array with strings and pick a random string?

The goal is to draw a random name from a hat using a switch command

String[] names = sc.next(); // how do I create an array of names with user 
input? also, see case a.

case 'a':
System.out.println("\nPlease enter the names of the participants.");
final String[] names = {sc.next()}; 

/*how do I add multiple names in one 
line? or by pressing enter for each additional name?*/

break;




Aucun commentaire:

Enregistrer un commentaire