Solved

Using DecimalFormat

Posted on 2004-04-11
3
747 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

762 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now