for (int i = 0; i < temp.length; i++){ temp[i] = if(!temp[i].trim().equals("") || temp[i]!=null)temp[i].trim(); }
String str = "Programming is easy to learn"; String result = str.replaceAll("s+","");