### Question:
StringUtil { static public String trim(String string){ int length = string.length(); int trimmedLength = length; while(trimmedLength > 0){ char c = string.charAt(trimmedLength - 1); if(!Character.isWhitespace(c)){ break; } trimmedLength--; } if(trimmedLength < length){ string = string.substring(0, trimmedLength); } return string; } private  StringUtil(); static String trim(String string);  }### Answer:
@Test public void trim(){ String string = ""; assertSame(string, StringUtil.trim(string)); string = "token"; assertSame(string, StringUtil.trim(string)); string = "\ttoken"; assertSame(string, StringUtil.trim(string)); string = "token\n"; assertEquals("token", StringUtil.trim(string)); string = "token\r\n"; assertEquals("token", StringUtil.trim(string)); string = "\ttoken\n"; assertEquals("\ttoken", StringUtil.trim(string)); string = "\ttoken\r\n"; assertEquals("\ttoken", StringUtil.trim(string)); }