Java. How to remove white space on array
java
Solution
simply loop thru the items in array like the one below and remove white space
for (int i = 0; i < temp.length; i++){
temp[i] = if(!temp[i].trim().equals("") || temp[i]!=null)temp[i].trim();
}
Problem
For example I split a string "+name" by +. I got an white space" " and the "name" in the array(this doesn't happen if my string is "name+"). ``` t="+name"; String[] temp=t.split("\\+"); ``` the above code produces ``` temp[0]=" " temp[1]=name ``` I only wants to get "name" without whitespace.. Also if t="name+" then temp[0]=name. I'm wondering what is difference between name+ and +name. Why do I get different output.