I have a programming homework. It says that I need to reverse the string first, then change it to uppercase and then remove all the whitespaces. I actually did it, but our professor didn't say anything about using replaceAll()
method. Is there any other way to do it beside replaceAll()
?
Here is my code:
public static void main(String[] args) {
String line = "the quick brown fox";
String reverse = "";
for (int i = line.length() - 1; i >= 0; i--) {
reverse = reverse + line.charAt(i);
}
System.out.println(reverse.toUpperCase().replaceAll("\\s", ""));
}
StringConcatFactory
explicitly states that it's for creating concatenators for a known number of inputs; use in a loop doesn't match its description. – Perplex