Related to variables

in this quistion i didnt understand how can we return i and z compilar is asking for local variables

hey @missroy I hope this will help.

  • Problem statement is quite easy you just need to tell whether the character entered is Lower case or Uppercase otherwise print I.
  • We can also compare characters directly without remembering the ascii codes.

Code

public static char tell(char ch) {
        if(ch >= 'a' && ch <= 'z')
            return 'L';
        else if(ch >= 'A' && ch <= 'Z')
            return 'U';
        else
            return 'I';
}

why we are taking &gt reference variable here

hey @missroy because we are comparing whether the current character lies within small alphabets or capital alphabets

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.

what it means &g in java

hey @missroy is a Bitwise AND logical operator.It will do the work of AND gate.

we are printing ascii value thats why we are using &g this

@missroy The code that I have provided you does not use &g anywhere

@missroy Can you please elaborate your doubt.

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.

this is my code import java.util.*; public class Main { public static void check(char ch) { if (ch >= ‘A’ && ch <= ‘Z’) { return ‘U’ ; } else if(ch >=‘a’ && ch <= ‘z’) { return ‘L’; } else { return ‘i’; } } public static void main(String []args) { char ch; Scanner s=new Scanner(System.in); ch=s.next().charAt(0); check(ch); } }

hey @missroy I have corrected your mistakes //Look for comments in between the code to see what was the mistake.
import java.util.*;

public class Main {
//here return type should be char bcoz you are returning char.
public static char check(char ch) {
if(ch >= ‘a’ && ch <= ‘z’)
return ‘L’;
else if(ch >= ‘A’ && ch <= ‘Z’)
return ‘U’;
else
//here I should be capital.
return ‘I’;
}

public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	char ch = s.next().charAt(0);
	//here  I have called the method from sysO statement bcoz we need to print the output given by it.
System.out.println(check(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.