Suppose I have a string as ABCDEFG
. I want to replace the even values of this string with their ASCII value. How should I do?
//STRING IS STORED IN str
for (int i = 0; i < str.length(); i++) {
if (i % 2 != 0) { //FOR EVEN SPACES
int m = str.charAt(i);
//GOT ASCII VALUE OF even spaces
System.out.println("Converted ASCII VALUES ARE" + m);
}
}