From fdc48cbc20eaf27d8fa95c9765a112fa6d57d47c Mon Sep 17 00:00:00 2001 From: CalebConner13 <30534014+CalebConner13@users.noreply.github.com> Date: Wed, 2 Aug 2017 14:10:09 -0400 Subject: [PATCH] Updated syntax / whitespace --- Misc/CountChar.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Misc/CountChar.java b/Misc/CountChar.java index dfdc0684d..1c8dcfea9 100644 --- a/Misc/CountChar.java +++ b/Misc/CountChar.java @@ -17,9 +17,7 @@ public class CountChar { System.out.println("There are " + CountCharacters(str) + " characters."); } - - - + /** * @param str: String to count the characters * @@ -30,12 +28,15 @@ public class CountChar { int count = 0; - if(str.isEmpty() || str == null) - return -1; + if(str == "" || str == null) //Exceptions + { + return 0; + } - for(int i = 0; i < str.length(); i++) - if(!Character.isWhitespace(str.charAt(i))) + for(int i = 0; i < str.length(); i++) { + if(!Character.isWhitespace(str.charAt(i))) { count++; + }} return count; }