Click to See Complete Forum and Search --> : DecimalFormat Class (Question on what the # does)


s3a
October 19th, 2009, 06:16 PM
Here is my code:
import java.text.DecimalFormat;

import java.util.Scanner;

public class decform_checker
{
public static void main (String [] args)
{
Scanner kb = new Scanner(System.in);

double number = kb.nextDouble();

DecimalFormat formatter = new DecimalFormat("#0,000.000%");
System.out.println(formatter.format(number));
}
}

I would appreciate it if somebody could explain what the # does in detail because I don't understand what I read on it and I don't find much to read about it either.

Thanks in advance!

holestary
October 20th, 2009, 01:04 AM
take a look Special Pattern Characters...

DecimalFormat (http://java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormat.html)