Why im having error in this code is there any problem

public class LoweUpper {

public static void check(String ch)
{
 
    if(ch >='A' && ch <= 'Z')
    {
        System.out.println("\n" + ch +
                " is an UpperCase character");
    }
 
    elseif (ch >= 'a' && ch <= 'z')
    {
        System.out.println("\n" + ch +
                " is an LowerCase character" );
    }
 
    else {
        System.out.println("\n" + ch +
                " is not an aplhabetic character" );
    }
}


public static void main(String []args)
{
   Scanner s=new Scanner(System.in);
   String str=s.nextLine();
   check(str);
   
 
}

}

hey @missroy the problem in this code is that in the function ch is a String but ing if condition you are comparing a String(Ch) with a Character that’s why it is giving a error

ok but we can declare String as charecter too?

hey @missroy No you cannot declare String as Character.
but you can convert a String to character using String.valueOf(Ch);

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.

im trying to compare charecter this is my code and it is giving an error

public class LoweUpper { public static void check(char[] ch) { if (ch >= ‘a’ && ch <= ‘z’) { System.out.println(“lowercase” ); } if(ch >=‘A’ && ch <= ‘Z’) { System.out.println(“UPPERCASE”); } else { System.out.println(“INVALID” ); } } public static void main(String []args) { Scanner s=new Scanner(System.in); int n=s.nextInt(); char ch[]=new char[n]; for(int i=0;i<n;i++) { ch[i]=s.next().charAt(0); } check(ch); } }