Program To Show Usage Of Trim Statement In Java

LEVEL: Beginner

Whats in this post?

  1. Code
  2. Output
  3. Background and Explanation of the code

Code


To copy code: Click  View Source “View Source” on the right of this code snippet.

Background and Explanation of the code

The program uses the trim() statement that returns a copy of the invoking string from which any leading and trailing whitespace has been removed. So the trimmed string is free from any leading or trailing spaces.