Error string cannot be converted to array

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc= new Scanner(System.in);
String str= sc.nextLine();
for(int i=0;i<str.length()-1;i++){
if(str[i]>=ā€˜A’&&str[i]<=ā€˜Z’){
System.out.println(str[i]);
}
}

}

}

@Shivam_balwani,

In CPP we use str[i].

In Java we use str.charAt(i)