Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Collections class

 
Sally Curtis
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic