```
public int longestPalindrome(String s) {
if (s == null) {
throw new IllegalArgumentException("Invalid Input");
}
int l = s.length();
if (l == 0) {
return 0;
}
int[] count = new int[256];
for (int i = 0; i < l; i++) {
count[s.charAt(i)]++;
}
int oddLength = 0;
int length = 0;
for (int currCount : count) {
if (currCount % 2 == 0) {
length += currCount;
}
else {
oddLength = Math.max(oddLength, currCount);
}
}
length += oddLength;
return length;
}
}'''
```