samedi 6 juin 2020

merge multiple keywords into a string

i am trying to write a program to take a random amount of multiple keywords from a String[] and merge them together into a String

    String keywords = "max,Max,Pro,pro,XS,xs,Xs,XR,xr,Xr,X,6,7,8,10,11,SE,se,Se,Plus,plus";
    String[] keywordArray = keywords.split(",");
    Random keywordSelector = new Random();
    int keywordIndex = keywordSelector.nextInt(21);
    String title = keywordArray[keywordIndex];          

    System.out.println("iPhone " + title);

current output example: iPhone X

how can i change the code so that i can achieve desired output example?: iPhone X 6 Max Pro 10 11 SE




Aucun commentaire:

Enregistrer un commentaire