[Solved] Convert each letter of string into ascii values – java


Well adding two Strings is simply concatenation using the + operator:

//first and second should be declared as String.
String both = first + second;

Look here to see how to remove duplicate characters from a String.

Lastly, the ascii value of a character is just the int value of that character. Because of this you can just do this:

int asciiSum = 0;
for (int i = 0; i < both.length(); i++){
    asciiSum += (int)both.charAt(i);
}

That will give you the sum of the ascii values in your String.

Hope this helps.

1

solved Convert each letter of string into ascii values – java