aspose file tools*
The moose likes Beginning Java and the fly likes Collections class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Collections class" Watch "Collections class" New topic
Author

Collections class

Sally Curtis
Greenhorn

Joined: Jan 10, 2004
Posts: 26
i keep getting the following errors
cannot resolve symbol
symbol : variable Collections
location: class PlayingCards
Collections.shuffle(Array.asList(cards));

cannot resolve symbol
symbol : variable Array
location: class PlayingCards
Collections.shuffle(Array.asList(cards));

and my code is



am doing something wrong here?

[EJFH: Added some newlines to code. ]
[ June 03, 2004: Message edited by: Ernest Friedman-Hill ]
Irina Goble
Ranch Hand

Joined: May 09, 2004
Posts: 91
Sally,

You can import the whole java.util package or just use full names for shuffle and asList



or call

[ June 03, 2004: Message edited by: Irina Goble ]
Irina Goble
Ranch Hand

Joined: May 09, 2004
Posts: 91
Sally,

If you call Collections.shuffle(Arrays.asList(deck)), you won't get any result as the shuffled list will be discarded.
You could make an ArrayList from deck, shuffle the list and then make an array out of the shuffled list:


PS. Why my posts are shifted? How can I fix this?

[ June 03, 2004: Message edited by: Irina Goble ]
[ June 03, 2004: Message edited by: Irina Goble ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by Irina Goble:

PS. Why my posts are shifted? How can I fix this?


It wasn't your fault, it was the really long line of code in Sally's post that messed up this whole page. It's fixed now.


[Jess in Action][AskingGoodQuestions]
 
 
subject: Collections class