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];
}
Hot today
Please help, any idea?
2 Votes
Loop question, I've tried everything that I knew I just don't know. Please help me solve it out
1 Votes
What is wrong? Error on test.
1 Votes
Help me solve this (using loop)
1 Votes
Help me wiht python
1 Votes
how can i flip any word with c++
0 Votes