0
What is the end of the text to reverse It to print the input text reversed??!
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String text = scanner.nextLine(); char[] arr = text.toCharArray(); for (string i=text;i<arr.length;i--){ arr[i]=i; } System.out.println(arr[i]); //your code goes here } }
2 Answers
+ 5
You need to review or research and try to code the part where it says.
If it doesn't work, share your attempt by using the code playground and someone can help.
+ 1
import java.util.Scanner;
public class Program {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String text = scanner.nextLine();
char[] arr = text.toCharArray(); //convert into character array
for(int i=arr.length-1; i>=0; i--){ //print from last index to first by
System.out.print(arr[i]);
}
}
}
// String i=text; valid but i--, i<arra.length are invalid.
//hope it helps..