The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Work around...

Posted by Kishori Sharan on April 18, 2001 at 12:38 PM

You cannot do directly what you are looking for. I think you have an int and you want to pass an argument or you want to work with an Object of Number class. You cannot directly cast an int or any primitive data type to a reference type. What you can do is create a Integer object as:
Integer num = new Integer ( your_int ) ;

Since Integer is a subclass of Number , you can use num anywhere you need Number.

Thanx
Kishori





Replies:
  • thanks Isbelle April 18, 2001 at 1:11 PM (0)

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us