Pablito
Pablito

Reputation: 197

How to turn a char to upper case in java without using String

Is there an easier way to do this?

public static void main(String[] args) {
    char x = 'a';     //If 'a' I want 'A', if 'z' i want 'Z', and so on.
    String aux = "";
    aux=""+x;
    aux=aux.toUpperCase();

    x=aux.charAt(0);
}

Upvotes: 3

Views: 5256

Answers (1)

M A
M A

Reputation: 72844

You can use Character.toUpperCase(char ch).

Upvotes: 15

Related Questions