Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cast int to Number

 
Isabelle Zorbios
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Does anybody know how to cast int to Number?
isabelle
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't cast from int to Number because int is a primitive type and Number is an object. Casting an object is changing the reference type from one type of object to another. You first have to have an object to work with.
What you will have to do is create an instance of Integer using the constructor Integer(int myInt). Integer is a subclass of Number, so you can use it like an instance of Number or cast it, as you choose. So here is an example of how you could get an integer variable, i into a Number object numObj:
 
Isabelle Zorbios
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok...
Thanks alot!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic