The moose likes Beginning Java and the fly likes number format 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 » Java » Beginning Java
Bookmark "number format" Watch "number format" New topic

number format

Maureen Charlton
Ranch Hand

Joined: Oct 04, 2004
Posts: 218
I have the following code:

I am confused to why I am getting the following output to screen:

Account details for:
This is the decimal format to two places: 600.00
Formating currency: java.text.DecimalFormat@67500
Steven Peter Charlton : Account No: 8945 Balance: 600.00

In particular the following line:
Formating currency: java.text.DecimalFormat@67500

Could someone please explain?
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
DecimalFormat doesn't implement the toString method and therefore uses the one inherited by Object. Take a look at the JavaDoc for both classes...

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Maureen Charlton
Ranch Hand

Joined: Oct 04, 2004
Posts: 218
Ilja Preuss, many thanks for your post.

Got the following code to work successfully:

I agree. Here's the link:
subject: number format
It's not a secret anymore!