Link to home
Start Free TrialLog in
Avatar of gootmundi
gootmundi

asked on

Using DecimalFormat

I'm attempting to use an object of the DecimalFormat class. However, I'm continually receiving the following when I attempt to compile:

"cannot resolve symbol class DecimalFormat"

for the lines where I create a new DecimalFormat object. My code is as such:
------------------------------------------------------------------
public class DecimalFormatDemo
{
      public static void main(String[] args)
      {
            DecimalFormat twoDigitsPastPoint = new DecimalFormat("0.00");
            DecimalFormat threeDigitsPastPoint = new DecimalFormat("00.000");
            
                        
            double d = 12.3456789;
            System.out.println(twoDigitsPastPoint.format(d));
            System.out.println(threeDigitsPastPoint.format(d));
            

      }
}
-------------------------------------------------------------------------

Any ideas what I'm doing wrong??
ASKER CERTIFIED SOLUTION
Avatar of venkateshwarr
venkateshwarr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
make sure you have the following line before your class declaration:
import java.text.DecimalFormat ;
Excuse me