?
Solved

Using DecimalFormat

Posted on 2004-04-11
3
Medium Priority
?
753 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

770 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