Consider a simple utility program in Java meant to reverse a given string. Some critical parts of this program are missing, denoted by the '▭'. Your task is to fill in the blanks in the code to ensure it correctly reverses and prints out the given input string 'Hello, world!' The input string is not going to change.
Processing strings
Complete the code to reverse a string
Report a typo
Fill in the gaps with the relevant elements
public class Main {
public static void main(String[] args) {
String input = "Hello, world!";
String reversed = "";
for (int i = input.() - 1; i >= 0; i--) {
reversed += input.(i);
}
System.out.println(reversed);
}
}Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.