• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue with wrapper class, not able to add a float value to an int variable  RSS feed

 
Vishal Hegde
Ranch Hand
Posts: 1078
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Issue with wrapper class

 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Integer's parseInt() method takes a String. If you just needed the int value from a double, first create a Double and then use the intValue() method.

Double.valueOf(some_double_value).intValue()
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Better still: don't use Math.random() at all. Have a look at the Random class (java.util.Random ← click); I think you'll find it has exactly the method you want.

Winston
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may be confusing parsing with casting. You might look them up to clarify when each is appropriate and how each is accomplished.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!