← Unit 1 · all exercises
Saved in this browser only

Tidy up the spaces

Return the text with any spaces at the very start and very end removed. Spaces in the middle stay. Note that the original String is not changed — the method hands you a new one.

String tidy(String text)

Solution.java
Loading editor…
Results

Examples

  • tidy( hello ) → hello
  • tidy(java) → java

There are also 3 hidden tests you can't see. Solve the problem, not the examples.