• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with Overloaded Constructor "Cannot resolve symbol"

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From within another class "BinaryTree" I'm testing if an object "BinaryNode" is null, and if it is, initialize it using a constructor. My problem is, if i initialize it with the default constructor "BinaryNode()" it works, however if I use the overloaded constructor "BinaryNode(int x)" it doesnt. It gives me a cannot resolve symbol. Is my problem with access? Or is it a memory issue in Java?

Here is the code for both classes, the problem is in bold:

BinaryTree class:


BinaryNode class:

 
Justin Swartsel
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow. I'm stupid. I figured out that when you have a void return type in front of a constructor it will do that to ya.

So, now that I know that, why is it the case?
 
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't have constructors for BinaryNode, you have methods that happen to have the same name as the class. Remove the return value "void" and you'll be okay.
 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Off the top of my head, I'd say you are probably not managing "x" in this situation.

You haven't supplied a copy of the call that creates the error, so I assumed that you mean to simply replace your bold type with your description.

If that is true, then you are using X as an argument of type BinaryNode and X as parameter as type int.

Double check this and let me know if it is still giving you an error. If so, please supply the code that is not correct.
 
jefff willis
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
wow. two quick answers in the time it took me to ask another question.
 
Jeff Bosch
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See my first answer: If you have a return value, you don't have a constructor, you have a method.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic