How does Increment operator work in Java?

My java code doesn't work?

  • The problem is the first line if (toBeRemoved.left = null || toBeRemoved.right = null) { Node newChild; if (toBeRemoved.left = null) newChild = toBeRemoved.right; else newChild = toBeRemoved.left; if (parent == null) root = newChild; else if (parent.left == toBeRemoved) parent.left = newChild; else parent.right = newChild; return; } that is the code, here is the error message: operator || cannot be applied to <nulltype>,Node

  • Answer:

    You need 2 equals signs: if (toBeRemoved.left = null || toBeRemoved.right = null) should be if (toBeRemoved.left == null || toBeRemoved.right == null) One equals is for assignment, 2 for comparison.

outbakse... at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

In the first line, try using == instead of =, so the it looks like this: if (toBeRemoved.left == null || toBeRemoved.right == null)

justgenius12

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.