+ 2
Cant find the problem to this
6 Respuestas
+ 5
import java.util.Scanner;
class stringReverse
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
char[] v=s.toCharArray();
for(int i=v.length;i>=1;i--)
{
System.out.print(v[i-1]);
}
}
}
+ 2
Nice it worked thanks guyz
+ 2
Thanks Martin Taylor that works too
+ 1
Thanks Reivin Dedstinguer though still it has errors even after changing the char name
+ 1
What characters blackwinter?
+ 1
The for loop was already got an i-- statement so you don't need to decrease i again. The last item of an array has an index of the decreament of the array length by 1. So item array[array.length] doesn't exists, that also makes you mistake at i>=1 since 1 is index of the second item of an array has more than 2 items.