Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Java Tutorial 8 - Random Number Generator

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
3,781
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Sep 21, 2010

pm me with questions or requests

  • likes, 1 dislikes

Link to this comment:

Share to:
see all

All Comments (10)

Sign In or Sign Up now to post a comment!
  • I thought it was this way: "sam" is an instance and Random is an object. "new Random()" creates a object and "sam" is the instance of "new Random()"

  • This method repeat randoms.

  • ¿porqué a mi no me funciona? ¿Porqué no me deja importar java.util.Random? :(

  • Random don't working to me why?

  • @anvandarnamnnr1 You would need to put (sam.nextInt(49)+1);

  • i did get a 0 from (sam.nextInt(49+1));

  • Actually nextInt(50) returns an integer between 0 and 49, both included. So nextInt(50)+1 would return only integers between 1 and 50

  • its called Libraries Radom util ect are libraries :D

  • Great tutorial! But what about doubles?

  • System.out.println (sam.nextInt(50)+1);

    because start from 0 (inclusive 0), and end at 50 (but EXCLUSIVE 50, so real end is at 49 -> +1 = 50)

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more