I thought typecasting to char we do the trick but it just prints ascii values
String str = JOptionPane.showInputDialog("Enter a word");
str = str.toUpperCase();
String temp = "";
for(int i = 0 ; i < str.length() ; i++)
{
temp += (char)str.charAt(i) + 1;
}
System.out.println(temp);
str.charAt(i) + 1is the likely culpritchartoint. You're casting it to acharthen adding 1 onto it. Put some brackets in.temp += (char) (str.charAt(i) + 1);, which takes thecharadds1to it (resulting in anint) and then casts the result back tochartemp += (int)str.charAt(i) + 1;str.charAt(i) is 'a'. Although OP wants the next alphabetic character not someintvalue.