I am trying to reverse all the strings in an array in java, but seem to over write all of them with the first.
private static void palindrome(String[] s) {
int flag=0;
String reverse;
for(int i=0;i<n;i++) // n is declared globally as number of strings
{
reverse="";
for (int j=s[i].length()-1;i>=0;i--)
reverse=reverse+s[i].charAt(j);
if(s[i].equals(reverse))
{
System.out.println(s[i]);
flag=1;
}
}
if(flag==0)
System.out.println("There are no palindromic strings");
}