Search⌘ K
AI Features

Solution Review: Finding the Right Words

Explore how to analyze and manipulate strings in Java using key methods such as trim to remove spaces, substring to extract parts of text, and toUpperCase to convert characters. This lesson helps you understand practical string processing for clean and effective code.

Solution:

...
Java
class HelloWorld {
public static void main( String args[] ) {
String text = " Names! Doe ";
String answer = "";
answer = text.trim();
answer = answer.substring(0, 6);
answer = answer.toUpperCase();
System.out.println(answer);
}
}
...