Declaring node info in Java

Discussion in 'Mac Programming' started by DesertFox, May 25, 2007.

  1. DesertFox macrumors member

    Joined:
    Nov 25, 2004
    #1
    Hello again,

    Im getting an error on the 4th line (node leftChild) of this Node code snippet.

    Error: cannot find symbol
    symbol: class node
    location: class node

    Is there a different way to declare nodes? or is there a syntax error?

    Thanks in advance!



     
  2. therevolution macrumors 6502

    Joined:
    May 12, 2003
    #2
    I'm going to take a wild guess and say it should be Node, not node. You have to match whatever case you used for the name of your class.

     
  3. DesertFox thread starter macrumors member

    Joined:
    Nov 25, 2004
    #3
    That seemed to fix that problem, but now Im getting a new one:

    Error: variable last might not have been initialized

    But, we can clearly see that it is initialized at the top of the method.

    Does anyone know whats going on here?

    Thanks!
     
  4. therevolution macrumors 6502

    Joined:
    May 12, 2003
    #4
    Actually, it's not being initialized. It's being declared. To initialize it, you need to explicitly assign a value to it (null is okay).

    Try changing that line to:
    Code:
    Node last = null; 
    
     

Share This Page