Reverse a string
My original code had a loop like this for (int t = arr.length; t >= 0; t- -){ } It did not work so I got this code to work after reading a post here, it was only missing this part from the loop: int a = arr.length; for(int t = a -1; Now it works but I would like to know how to display the results in one line instead of scrolling down. Sorry for the explanation above, I was only trying to show that there was no way I would have figured this out with what I know about coding up to now. 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(); //your code goes here int a = arr.length; for (int t = a - 1; t >= 0; t--){ System.out.println(arr[t]); } } }