Java String trim() Method

String Methods : Remove whitespace from both sides of a string

Definition and Usage

The trim() method removes whitespace from both ends of a string.

Note: This method does not change the original string.

Syntax

public String trim()

Parameters

None.

Technical Details

Returns: A String value, which is a copy of the string, without leading and trailing whitespace

❮ String Methods