• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Random integers

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Need to ask u guys a question
Is there any codes that can help me get two random number ?
thnks^^
 
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch! There's a method in the class java.util.Random called nextInt which can generate a uniform distribution for you. As an example, the code
(assuming an "import java.util.Random" or "import java.util.*" up top)

Could print out 0, 1, 2, 3, or 4. More information about the Random class in the official documentation.
On a seperate note, please review our naming policy and modify your display name to meet the guidelines. Thank you!
 
reply
    Bookmark Topic Watch Topic
  • New Topic