Language
Version: SE 8
Categories
-
User Program Communication
-
Variables
-
Control Flow
-
Object Oriented Programming
-
String Class
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!"