String Index Out of Bound error

I tried to code a problem which include this lesson and if user input more than one character then print each character one by one

but the problem is that gives an exception and I don’t know it does the work that means it prints each character one by one but in the end, I have an exception can you please help me why is this happening

Hi @radhagovinda008,
in try block in the for loop you have to do i<s.length.
like this:
try {
if(s.length()>1){
for(int i=0;i<s.length();i++){
char ch=s.charAt(i);
System.out.print(ch);
}
}