This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Please help  RSS feed

 
Lesole Mphinyane
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, i've got a problem..
How do i print numbers between 0 & 10 in random. (not in sequence)?..
Waiting to here from you soon..
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To generate random numbers, you can use the class java.util.Random. Look it up in the API documentation.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you could put the numbers 1 to 10 in a List of some sort and then use the Collections.shuffle() method. You would need to create Integer objects to do this rather than using primitive ints.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!