When you say the largest String value do you mean as in size, or do you mean as in b > a < c meaning alphabetical order? For that you would need something like this:
String a = "aaaaa";
String b = "bb";
char[] aAr = a.toCharArray();
char[] bAr = b.toCharArray();
int lenA = 0, lenB = 0;
for (int i = 0; i < aAr.length; i++) {
lenA += aAr[i];
}
for (int i = 0; i < bAr.length; i++) {
lenB += bAr[i];
}
System.out.println(lenA + " " + lenB);
Note that what this code does is first convert the String to a charcter array, then adds their ASCII codes together, meaning that a = 97, while b = 98, b > a. You are going to get problems when it comes to capitals though, since a = 97, while CAPITAL B = 66 making it a > B. One solution is to just convert everything to lowercase before you check it. The other one is a little more complicated, it involves changing the for loops:
String a = "a";
String b = "A";
char[] aAr = a.toCharArray();
char[] bAr = b.toCharArray();
int lenA = 0, lenB = 0;
for (int i = 0; i < aAr.length; i++) {
if (aAr[i] >= 90 || aAr[i] < 65)
lenA += aAr[i];
else
lenA += aAr[i] + 64;
}
for (int i = 0; i < bAr.length; i++) {
if (bAr[i] >= 90 || bAr[i] < 65)
lenB += bAr[i];
else
lenB += bAr[i] + 64;
}
System.out.println(lenA + " " + lenB);
What this does is simple:
It evaluates the character, if the character value is greater than 54 (so we cover in case there are numbers in the string, 1-9 or other chars) but less then 90, we assume that the value is a capital letter. Then we add to the size the value of the letter + 64, (twice the difference between the lowercase characters, and the uppercase characters).