+ 3
Reverse of a array
Pls find the error
4 Answers
+ 3
When iterating backwards the first index should be arr.length -1, not arr.length.
+ 3
Use i>=0 rather than i>0 when iterating backwards.
+ 2
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();
char[] c;
//your code goes here
for(int i=arr.length;i>0;i--)
c[]=arr[i];
for(int i=0;i<arr.length;i++)
System.out.print(c[]);
}
}
+ 2
Rwemember to smwile :)
Smwiling is evwey thing in da world