Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Random Number from Math

 
Shiny
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can the 'random' method of Math class return 0.0 and 1.0 ? I think, 0.0 is inclusive while 1.0 is NOT.
some one please confirm,
thanks
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Shiny , that is what the documentation also says.To quote the Java2API
"Returns a random number greater than or equal to 0.0 and less than 1.0."
 
mmkris_1
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[0,1)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic