This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "How to use "toHexString"?" Watch "How to use "toHexString"?" New topic

How to use "toHexString"?

lauren bai

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 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

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
lauren bai

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:
subject: How to use "toHexString"?
It's not a secret anymore!