Solved

Using DecimalFormat

Posted on 2004-04-11
3
749 Views
Last Modified: 2012-06-21
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??
0
Comment
Question by:gootmundi
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
venkateshwarr earned 50 total points
ID: 10800223
did you import

import java.text.NumberFormat;
 
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10800234
make sure you have the following line before your class declaration:
import java.text.DecimalFormat ;
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10802857
Excuse me
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
github account with ecipse 1 47
how to add new optional parameter to JSP 1 41
table example 4 29
How to determine if a string is a valid SHA value 7 34
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question