From 8a03144a43feb940dafe06bed8ccb83269b94d35 Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Wed, 11 Dec 2019 12:50:56 -0600 Subject: Get rid of kludge try-catch and replace with if --- csci1913/Java/project3/project3_strap012.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/csci1913/Java/project3/project3_strap012.java b/csci1913/Java/project3/project3_strap012.java index 16290aa..0bed110 100644 --- a/csci1913/Java/project3/project3_strap012.java +++ b/csci1913/Java/project3/project3_strap012.java @@ -69,7 +69,7 @@ class AnagramTree { } private void findAnagrams(TreeNode subtree) { - try { + if (subtree != null) { if (subtree.words.next != null) { System.out.println(); while (subtree.words != null) { @@ -78,16 +78,8 @@ class AnagramTree { subtree.words = subtree.words.next; } } - if (subtree != null) { - findAnagrams(subtree.left); - findAnagrams(subtree.right); - } - } catch (NullPointerException ignore) { - /* - This exception exists as a kludge for any time - subtree is null. The program does bad things - if this is not present. - */ + findAnagrams(subtree.left); + findAnagrams(subtree.right); } } -- cgit v1.2.3