trim() method is useful within a start of string or end of string but its not working for WHITE SPACE between the two strings .
Here is example to remove space between two String using regex:-
public class RemoveSpace {
public static void main(String[] args) {
String username="Jack Sparrow";
System.out.println(username.replaceAll("\\s", ""));
}
}

No comments:
Post a Comment