0
Reversing are char
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(); // Any other way aside my solution given below. //your code goes here int arrLen = arr.length; for(int i = arrLen; i >= 0; i--){ System.out.println(arr[i]); } } }
1 Answer
0
If you want to reverse an array in java manually, you can do this:
int arrLen = arr.length();
char newArr[arrLen];
for (int i = 0, x = arrLen; i < arrLen; i++, x--) {
newArr[i] = arr[x];
}