Skip to content

Commit

Permalink
fix: Use .equals() to compare two strings in Java (#961)
Browse files Browse the repository at this point in the history
  • Loading branch information
selear authored Nov 21, 2023
1 parent 9b35f75 commit 5b6fb34
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions codes/java/chapter_tree/array_binary_tree.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ private void dfs(Integer i, String order, List<Integer> res) {
if (val(i) == null)
return;
// 前序遍历
if (order == "pre")
if ("pre".equals(order))
res.add(val(i));
dfs(left(i), order, res);
// 中序遍历
if (order == "in")
if ("in".equals(order))
res.add(val(i));
dfs(right(i), order, res);
// 后序遍历
if (order == "post")
if ("post".equals(order))
res.add(val(i));
}

Expand Down

0 comments on commit 5b6fb34

Please sign in to comment.