Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2009
    Posts
    4
    Rep Power
    0

    Default [SOLVED] Cannot find symbol error?

    Hi, I'm trying to create a priority queue based on the probabilities of chars as provided by a text file. However, on line 91 when I create a new node, it yields an error:

    line 91: CharNode node = new CharNode();
    cannot find symbol
    symbol: constructor CharNode()
    location: class CharNode

    CharNode class:

    class CharNode
    {
    // data members, all of which may need to be private
    char c;
    double prob;
    CharNode left, right;

    public CharNode(double p, CharNode l, CharNode r)
    {
    prob = p;
    left = l;
    right = r;
    c = 0;
    }

    public CharNode(char c, double p)
    {
    this.c = c;
    left = null;
    right = null;
    prob = p;
    }

    public CharNode getLeft()
    {
    return this.left;
    }

    public CharNode getRight()
    {
    return this.right;
    }

    public char getC()
    {
    return this.c;
    }

    public double getProb()
    {
    return this.prob;
    }

    }

    Why is that (I'm sure it's some stupid mistake)? Thanks in advance!
    Last edited by battousaibounty; 03-04-2009 at 03:46 AM.

  2. #2
    paul pasciak is offline Senior Member
    Join Date
    Jul 2008
    Posts
    125
    Rep Power
    0

    Default

    This is not an obvious mistake.

    Add a contructor to your CharNode
    that has the following signature:

    CharNode(){}

    The compiler makes this request
    because you have another constructor
    in CharNode. Because of that
    constructor's presence, you must
    specify this other constructor.

    It's a confusing rule to get used to,
    but it does make sense after you
    consider it about two dozen times.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You're calling a default constructor for CharNode, a constructor without parameters, and no constructor like this exists.

  4. #4
    Join Date
    Mar 2009
    Posts
    4
    Rep Power
    0

Similar Threads

  1. [SOLVED] Cannot find symbol error
    By dan0 in forum New To Java
    Replies: 17
    Last Post: 03-03-2009, 06:09 PM
  2. Replies: 9
    Last Post: 10-18-2008, 09:26 PM
  3. 'Cannot find symbol' error
    By minihazard10 in forum New To Java
    Replies: 6
    Last Post: 10-10-2008, 05:05 AM
  4. Error: cannot find symbol
    By silvia in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 06:39 AM
  5. Error: cannot find symbol
    By cachi in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 09:12 PM

Posting Permissions

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