-2

im trying to shuffle music tracks with the collections im unsure of on how to do this.

public void Shuffle()
{
   Collections ArrayList<Track>;

}

what i started with ^

Rajesh
  • 24,354
  • 5
  • 48
  • 79

2 Answers2

1

You can use Collections.shuffle(List list)

More to read: Oracle Documentation

krmaj
  • 15
  • 4
1

Example

public class Random {

        public static void main(String[] args) {
            List<String> teamList=Arrays.asList("Ananaya", "Mike","James", "Shashwat");

            Collections.shuffle(teamList);
            int counter=0;
            for (String value:teamList){

                System.out.println("The build schedule for week "+ ++counter + " is to be done by "+value);

            }       
        }
    }
shashwatZing
  • 1,550
  • 1
  • 17
  • 24