Results 1 to 6 of 6
  1. #1
    MBD
    MBD is offline Member
    Join Date
    Sep 2011
    Location
    Sale, Cheshire
    Posts
    10
    Rep Power
    0

    Default "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.

  2. #2
    Thiruppathi is offline Member
    Join Date
    Sep 2011
    Posts
    5
    Rep Power
    0

    Default 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.

  3. #3
    f22raptor is offline Member
    Join Date
    Aug 2011
    Posts
    16
    Rep Power
    0

    Default Re: "Cannot find symbol" error

    yes exactly try changing the class name. it should work,

  4. #4
    MBD
    MBD is offline Member
    Join Date
    Sep 2011
    Location
    Sale, Cheshire
    Posts
    10
    Rep Power
    0

    Default Re: "Cannot find symbol" error

    Thanks for replies, although changing the class name still gives the same error.

  5. #5
    Thiruppathi is offline Member
    Join Date
    Sep 2011
    Posts
    5
    Rep Power
    0

    Default 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.

  6. #6
    MBD
    MBD is offline Member
    Join Date
    Sep 2011
    Location
    Sale, Cheshire
    Posts
    10
    Rep Power
    0

    Default Re: "Cannot find symbol" error

    Hi Thiruppathi,

    Thanks for that, it worked.

    (I owe you one) cheers.

    MBD

Similar Threads

  1. "cannot find symbol" error
    By droidus in forum New To Java
    Replies: 2
    Last Post: 09-07-2011, 07:43 AM
  2. Replies: 5
    Last Post: 04-24-2011, 03:21 PM
  3. "Cannot find symbol" errors in Java
    By 23Zone in forum New To Java
    Replies: 1
    Last Post: 02-17-2010, 07:13 AM
  4. Error "can not find symbol variable"
    By FullMetalHollow in forum New To Java
    Replies: 5
    Last Post: 10-04-2009, 09:51 PM
  5. "Cannont find symbol Constructor" error
    By Welsh in forum New To Java
    Replies: 7
    Last Post: 01-25-2008, 12:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •