Merge pull request #76 from CalebConner13/patch-1

Updated syntax / whitespace
This commit is contained in:
Rohit Gupta
2017-08-08 13:19:47 +05:30
committed by GitHub

View File

@ -18,8 +18,6 @@ public class CountChar {
System.out.println("There are " + CountCharacters(str) + " characters."); System.out.println("There are " + CountCharacters(str) + " characters.");
} }
/** /**
* @param str: String to count the characters * @param str: String to count the characters
* *
@ -30,12 +28,15 @@ public class CountChar {
int count = 0; int count = 0;
if(str.isEmpty() || str == null) if(str == "" || str == null) //Exceptions
return -1; {
return 0;
}
for(int i = 0; i < str.length(); i++) for(int i = 0; i < str.length(); i++) {
if(!Character.isWhitespace(str.charAt(i))) if(!Character.isWhitespace(str.charAt(i))) {
count++; count++;
}}
return count; return count;
} }