?
Solved

Using DecimalFormat

Posted on 2004-04-11
3
Medium Priority
?
771 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 150 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month17 days, 8 hours left to enroll

830 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