Java trim string array
July 14, 2011 11:50:28 Last update: July 14, 2011 11:50:28
This is not to make the size of the array smaller, but to remove the leading and trailing spaces in each element.
This works:
This does not work:
This works:
String[] a = { " 1 ", " 2 " }; for (int i = 0; i < a.length; i++) { a[i] = a[i].trim(); }
This does not work:
for (String s: a) { s = s.trim(); }
Easy email testing with http://www.ximailstop.com