• Register
0 votes
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’t work how. Can anyone help me out?

10 7 2
6,050 points

1 Answer

0 votes
You have to learn how to use the Character.isLowerCase() method.isUpperCase() to determine if a letter is in an uppercase form. This method also return a boolean value that indicates whether the character is in uppercase form or not:
 public static void main(String[] args) {
        char a = 'A';

        // Checks to see if a letter is a uppercase letter.
        if (Character.isUpperCase(a)) {
            System.out.println(a + " is an uppercase character.");
You can also try this:
public static void main(String[] args)
		char ch;
		Scanner sc = new Scanner(System.in);
		ch = sc.next().charAt(0);
		if(ch >= 65 && ch <= 90)
		else if(ch >= 97 && ch <= 122)
		else if(ch >= 48 && ch <= 57)


11 6 4
34,930 points

Related questions

0 votes
1 answer 17 views
I was doing my java programming practice. I wrote a code to check if a charcter is a number: public static void main(String[] args) { String string = "-1234.15"; String numeric ; numeric = string.matches("-?\\d+(\\.\\d+)?"); if(numeric) System.out.println(string + " is a number"); else System.out.println(string + " is not a number"); } But it gives me error. Whats wrong in my code?
asked Mar 15 LizzyM 6.1k points
1 vote
1 answer 81 views
Problem: 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&rsquo;s say I&rsquo;ve given a char as &lsquo;a&rsquo; and I want ... , 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.
asked Mar 22 Gavin 15.3k points
0 votes
1 answer 2 views
I need to check if a number is a perfect squre in java.
asked Oct 5 Daniel Anderson 4k points
1 vote
1 answer 22 views
Problem: Hello good people, I am a novice in java programming. I am learning java online and solving problems daily. Today I got a problem that says to check if input is a number. How can I check it? Is it require a scanner class? Could anybody here help me to solve this problem, please?
asked Apr 7 Gavin 15.3k points