public class NumTest {
public static void main(String[] args) {
String s = " a c d ";
// System.out.println(s.trim());
s = myTrim(s);
System.out.println(s);
}
public static String myTrim(String s) {
StringBuilder sb = new StringBuilder();
String str = null;
for (int i = 0; i < s.length(); i++) {
str = s.substring(i,i+1);
if (!str.equals(" ")) {
sb.append(str);
}
}
return sb.toString();
}
}