To trim a
String
in Java, use the trim()
method.Here's how you do it:
String string = " Hello World! ";
String trimmedString = string.trim();
System.out.println(trimmedString); // Hello World!
String
in Java, use the trim()
method.Here's how you do it:
String string = " Hello World! ";
String trimmedString = string.trim();
System.out.println(trimmedString); // Hello World!