dekros
dekros

Reputation: 59

how to shuffle list(arrayList> with my own objects?

when i make somethink like this:

    List<Player> gamers = JackpotGame.getUnsortedGamerList();
    gamers = Collections.shuffle(gamers);

but i have error: http://scr.hu/1det/a13hi im sure that method getUnsortedGamerList return me List

Upvotes: 1

Views: 73

Answers (3)

Abdelhak
Abdelhak

Reputation: 8387

shuffle randomly permutes the specified list using a default source of randomness, and has no return.

Try to change this:

 gamers = Collections.shuffle(gamers);

With:

Collections.shuffle(gamers);

Upvotes: 0

Eran
Eran

Reputation: 393771

change

gamers = Collections.shuffle(gamers);

to

Collections.shuffle(gamers);

shuffle mutates the passed List instance and has no return value.

Upvotes: 1

Mohammed Aouf Zouag
Mohammed Aouf Zouag

Reputation: 17132

Change

gamers = Collections.shuffle(gamers);

to

Collections.shuffle(gamers);

The static shuffle method of the Collections class has a void return type.

Upvotes: 0

Related Questions