lundi 14 janvier 2019

Hi , i am working with music player, and i need to play a random songs in my arraylist, how can i do that?

Can i use some of those methods?

private ArrayList<Song> randomizeArrayList(ArrayList arrayList) {

//first look like this:

int b = 0;
int index = (int)(Math.random()*b);

System.out.println("number is " + index);

//second:

Random r = new Random();
System.out.println("random 2 " + r.nextInt(arrayList.size()));

//third:

int index1 = (int)(Math.random()*arrayList.size());
System.out.println("\nIndex :" + index );
return (ArrayList<Song>) arrayList.get(index1);

// return arrayList;

}




Aucun commentaire:

Enregistrer un commentaire