The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

but i get the error cannot make a static reference to a non static method size from type BinaryNodeWithSize
i have encounter this problem with insert delete etc also and thats which i made them static. can you tell where is the problem with the code? i want to be able to make non static methods and escpecially one with the size of the node.

Re: Problem with binary tree

You are trying to use the methods of BinaryNodeWithSize in a static context (eg BinaryNodeWithSize.insert()), which is why you are receiving the errors. Rather, you should be doing in the context of the object you created (eg instance methods)

In this way, the methods should not be static so they may refer to the object specific variables. While it doesn't have to be, the method size() can be placed within the BinaryNodeWithSize as opposed to its own class.

Re: Problem with binary tree

yes you was right,. i have fix this.
now i want with this code to be able to delete nodes. i have try to do it but i cant set value null. how i can delete a node? for example i want to delete the min and max node. this is what i have done: