Thursday January 22, 2015, 14:30-15:00 Lab 02 Version G
/**
* Test 1 utility class that provides fields and methods for working with
* strings.
*
*/
public class TestG {
/**
* The char equal to a single space.
*/
public static final char CHAR_SPACE = ' ';
/**
* Checks if a string s is made up of one or more TestG.CHAR_SPACE
* characters. Returns false if the string s is null.
*
* @param s
* a string to check
* @return true if every character of s is equal to TestG.CHAR_SPACE, false
* otherwise.
*/
public static boolean isAllSpaces(String s) {
if (s == null || s.isEmpty()) {
return false;
}
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) != TestG.CHAR_SPACE) {
return false;
}
}
return true;
}
private TestG() {
}
}