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

6.1k points

Please log in or register to answer this question.

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)
			System.out.print(“Upper”);
		else if(ch >= 97 && ch <= 122)
			System.out.print(“Lower”);
		else if(ch >= 48 && ch <= 57)
			System.out.print(“Number”);
		else
			System.out.print(“Symbol”);
	}

 

35k points