From bb84df27cfbf32f05852ece0c33f21d544cb8ac4 Mon Sep 17 00:00:00 2001 From: sjinzh <99076655+sjinzh@users.noreply.github.com> Date: Sat, 14 Jan 2023 20:47:03 +0800 Subject: [PATCH] fix bugs in java codes using JDK 1.8.0 --- codes/java/chapter_tree/binary_tree_bfs.java | 2 +- codes/java/include/TreeNode.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/codes/java/chapter_tree/binary_tree_bfs.java b/codes/java/chapter_tree/binary_tree_bfs.java index ffeb352e0..81895dd4a 100644 --- a/codes/java/chapter_tree/binary_tree_bfs.java +++ b/codes/java/chapter_tree/binary_tree_bfs.java @@ -13,7 +13,7 @@ public class binary_tree_bfs { /* 层序遍历 */ static List hierOrder(TreeNode root) { // 初始化队列,加入根结点 - Queue queue = new LinkedList<>() {{ add(root); }}; + Queue queue = new LinkedList() {{ add(root); }}; // 初始化一个列表,用于保存遍历序列 List list = new ArrayList<>(); while (!queue.isEmpty()) { diff --git a/codes/java/include/TreeNode.java b/codes/java/include/TreeNode.java index 22a349747..5a87e8a7b 100644 --- a/codes/java/include/TreeNode.java +++ b/codes/java/include/TreeNode.java @@ -32,7 +32,7 @@ public class TreeNode { return null; TreeNode root = new TreeNode(list.get(0)); - Queue queue = new LinkedList<>() {{ add(root); }}; + Queue queue = new LinkedList() {{ add(root); }}; int i = 0; while(!queue.isEmpty()) { TreeNode node = queue.poll(); @@ -58,7 +58,7 @@ public class TreeNode { public static List treeToList(TreeNode root) { List list = new ArrayList<>(); if(root == null) return list; - Queue queue = new LinkedList<>() {{ add(root); }}; + Queue queue = new LinkedList() {{ add(root); }}; while(!queue.isEmpty()) { TreeNode node = queue.poll(); if(node != null) {