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
commit 001223fc5c

View File

@ -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;
}