Mat
Mat

Reputation: 45

The assigned value is never used - Java

In my code I have the following lines:

 BinaryTreeNode temp = new BinaryTreeNode();
 temp = left;
 while(temp != null)
     temp = temp.left;

 temp.left = newNode; 

My IDE now says that: "the assigned value is never used" on the first line. I am probably declaring something wrong.

Upvotes: 1

Views: 2363

Answers (1)

Kayaman
Kayaman

Reputation: 73528

You're creating a BinaryTreeNode, then throwing it away instantly (with temp = left;). The IDE is warning you about whether you really intend to do that.

You could use null instead, or assign left directly to temp.

Upvotes: 5

Related Questions