Updated syntax / whitespace

This commit is contained in:
CalebConner13
2017-08-02 14:10:09 -04:00
committed by GitHub
parent 0e48afc53b
commit fdc48cbc20

View File

@ -17,9 +17,7 @@ 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;
} }