"Cannot find symbol" error
Hi, Hope someone can offer help on this. I get the "Cannot find symbol" error when trying to compile the code below. I cannot see what the problem is, if anyone can help I would really appreciate it.
import java.util.*;
import java.text.*;
public class NumberFormat {
public static void main(String[] args) {
float f1 = 456.789f;
Locale locSP = new Locale("es"); // SPAIN
NumberFormat[] nfa = new NumberFormat[4];
nfa[0] = NumberFormat.getInstance();
nfa[1] = NumberFormat.getInstance(locSP);
nfa[2] = NumberFormat.getCurrencyInstance();
nfa[3] = NumberFormat.getCurrencyInstance(locSP);
for(NumberFormat nf : nfa)
System.out.println(nf.format(f1)); }} Thanks MBD.
Re: "Cannot find symbol" error
Hi,
Change the class name as NumberFormat1 and save the file name as NumberFormat1.java.
We have to differentiate user defined class and in built class.
Re: "Cannot find symbol" error
yes exactly try changing the class name. it should work,
Re: "Cannot find symbol" error
Thanks for replies, although changing the class name still gives the same error.
Re: "Cannot find symbol" error
Please remove the file NumberFormat.java from your working directory and compile the code with new file. It gives the solution.
Re: "Cannot find symbol" error
Hi Thiruppathi,
Thanks for that, it worked.
(I owe you one) cheers.
MBD