```
public String longestPalindrome2(String s) {
if(s == null ||s.length()<=0)
return null;
char[] c = s.toCharArray();
for(int len = c.length ;len>1;len--){
for(int start=0;start<=c.length-len;start++){
int i=start,j = start+len-1;
while(i<=j && c[i] == c[j])
{
i++;
j--;
}
if(i>=j)
return s.substring(start,start+len);
}
}
return s.substring(0,1);
}
```