Question

Locked

java reference to a static method

By rajagitam ·
NumberFormat nf=NumberFormat.getNumberInstance();
nf.setMaximumFractionDigits(6);


what does the above code mean?
whats the nf reference refering to?

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Use google

by choehne In reply to java reference to a stati ...

Do this google search: java api NumberFormat, you get a pointer to http://java.sun.com/j2se/1.4.2/docs/api/java/text/NumberFormat.html

Collapse -

NumberFormat Static Method

by geosan In reply to java reference to a stati ...

The code means that you are invoking a method that belongs to the class not an instance of a class. The method will return a NumberFormat instance which defaults to the number format of the current locale.
Since NumberFormat is an abstract class, the instance of the NumberFormat class that you get when invoking the NumberFormat.getNumberInstance will provide you an interface for formatting and parsing numbers for the current locale.

You can change your locale by getting the instance like this
NumberFormat nf = NumberFormat.getInstance(Locale.FRENCH);

Back to Software Forum
3 total posts (Page 1 of 1)  

Software Forums