• Register
1 vote


I am looking for a solution to my existing code. Well, I am a new student of java. I was thinking about a program that can check whether the given char is an upper case or not!

Let’s say I’ve given a char as ‘a’ and I want to check this char is in upper case or lowercase! So, my question is, how to check whether a char variable ch is an uppercase letter, you write?

Thanks for your valuable time and effort guys.

12 7 7
15,250 points

Please log in or register to answer this question.

1 Answer

1 vote
Best answer


You got a nice question, man. It is easily can be founded in java whether the input is an uppercase or lowercase by calling a function name toUpperCase(). It returns a boolean type value, but I decided t write a code for you where we can check our input in various ways. Let’s do it.


public class UperCaseLowerCase 
    static void checker(char ch)  
        if (ch >= 'A' && ch <= 'Z')  
            System.out.println("\n" + ch +  
                    " is an UpperCase character");  
        else if (ch >= 'a' && ch <= 'z')  
            System.out.println("\n" + ch +  
                    " is a LowerCase character" );  
            System.out.println("\n" + ch +  
                    " is not an aplphabetic character" );  
    public static void main(String []args) 
        char ch;  
        ch = 'A';  
        ch = 'a';
        ch = '0';  

This program should throw back the output below:

A is an UpperCase character
a is a LowerCase character
0 is not an alphabetic character

Please reply to this thread if you have confusion regarding to this answer. Keep asking, please.

13 9 6
94,240 points

Related questions

0 votes
1 answer 10 views
0 votes
1 answer 33 views
I am very new at java programing, I have an assginment where I have to check if a character is uppercase in java and I wrote a code: public static void main(String[] args) { int A; char a = A; if (Character.isUpperCase()) { System.out.println(a + " is an uppercase character."); } } But it doesn&rsquo;t work how. Can anyone help me out?
asked Mar 15, 2020 LizzyM 6.1k points
0 votes
1 answer 22 views
I am new to python programming I was trying to check if a letter is uppercase in python. I wrote some code to check this statement : import string def UpperCase(s_str): for x in s_str: if x not in string.UpeerCase: return False return True But I can not get the actual ... last): File "<stdin>", line 1, in <module> NameError: name 'LoWWE' is not defined Can anyone help me to solve this thing?
asked Mar 14, 2020 LizzyM 6.1k points
0 votes
1 answer 9 views
1 vote
1 answer 20 views
Problem: Folks, I hope you are doing well. I started learning java programming very recently. I am on the chapter of Data Type right now of the book from where I am taking the help. There is a problem give in my book&rsquo;s exercise that: &ldquo;if you want to ... . Is it really possible to do so? If so, then how? Could you please give a hint regarding the problem given above? Best regards.
asked Mar 17, 2020 Gavin 15.3k points
0 votes
1 answer 23 views
Problem: I want to know whether the character at a certain index in a string is a number or not in C++. Moreover, I wanna see whether the user entered a number as input to a character variable or some other character. How can I do that?
asked Oct 21, 2020 Code Learner 5.1k points
0 votes
1 answer 32 views
I wrote a program like this Scanner in = new Scanner(System.in); System.out.println("Input a letter"); String line = in.nextLine(); char c = line.charAt(0); if( character.isDigit(c)) System.out.println(c +" Is a digit"); else if (character.isLetter(c)) System.out.println(c +" Is a Letter"); And It gives me error. How can I solve this problem?
asked Mar 12, 2020 LizzyM 6.1k points