← All Exercises
Java StringBuilder Operations
basicjava
Background
StringBuilder provides mutable string operations, avoiding the overhead of String concatenation in loops.
Problem
Write a Java method that takes a string, reverses each word, and joins them back using StringBuilder for efficiency.
Input
A string of space-separated words.
Output
A string with each word reversed.
Sample tests
Sample 1
Input: "hello world"
Expected: "olleh dlrow"
Your solution
Learning objective
Learn StringBuilder for efficient string building, reversal, and the performance vs String concatenation.