String-Max frequency Charecter

My code is giving incorrect answer most of the time. What is the mistake?

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
String str = scn.nextLine();
int [] charray = new int[26];
for(int i = 0;i < str.length();i++){
charray[str.charAt(i) - ‘a’]++;
}
int max = -1;
int index = 1;
for(int i = 0;i<=25;i++){
if(charray[i]>max){
max = charray[i];
index = i+1;
}
}
System.out.print(str.charAt(index));
}
}

just change the last line to Sopln((char)(iindex - 1 + ‘a’));

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.