This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Collections class

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic