my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes How to use Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "How to use "toHexString"?" Watch "How to use "toHexString"?" New topic
Author

How to use "toHexString"?

lauren bai
Greenhorn

Joined: Apr 08, 2005
Posts: 18
I create a class as follows:
class DoubletoHexString {

public static void main(String[] args) {

Double a = new Double(Double.NaN);

System.out.println("a: " + a.doubleValue());
System.out.println("doubletoHexString: " + Double.toHexString(a.doubleValue()));
}
}


I got compile error
DoubletoHexString.java:8: cannot resolve symbol
symbol : method toHexString (double)
location: class java.lang.Double
System.out.println("doubletoHexString: " + Double.toHexString(a.doubleValue()));


I check my spelling is correct. Can anybody tell why it's not correct?
[ April 14, 2005: Message edited by: lauren bai ]

SCJP (In Progress)
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

The code is correct. In Float and Double, the toHexString method is new with Java 1.5, so I'm guessing that you are using an earlier version compiler.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
lauren bai
Greenhorn

Joined: Apr 08, 2005
Posts: 18
Hi,Marc, you are so right. I even didn't notice that.
I study 1.5 API but run on 1.4.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use "toHexString"?