简体   繁体   中英

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM