dimanche 15 novembre 2020

Print array random JAVA [closed]

This is my txt "apple","banana","strawberry","orange","peach"

Random rnd = new Random();
String currentLine = scn.nextLine();
                String[] sale = currentLine.split(",");
 

String Fruits = sale.nextLine();
                        String[] ListF = Frutas.split(",");
                        String Delivery1= ListF[rnd.nextInt(ListF.length)];
                        String Delivery2 =ListF[rnd.nextInt(ListF.length)];
System.out.println("Cliente" + " "+ Delivery1 + Delivery2);

Output

output Cliente (apple) (peach) (strawberry)

ERROR Cliente (apple)(apple)(apple) client can get min 1 max 3 fruits.



Aucun commentaire:

Enregistrer un commentaire