String Class

String Trim in Java

Used to remove trailing and leading whitespace in a string.


Syntax
String trimmedString = stringName.trim();

Notes


Example
String untrimmed = "Welcome to SyntaxCenter!   ";
String trimmed = untrimmed.trim();
System.out.println(trimmed); //should output "Welcome to SyntaxCenter!"

Add to Slack

< String Compare   |   Split String >

© 2018 SyntaxDB. All Rights Reserved.