Mido Mido - 3 months ago 14
Java Question

What is the difference between char and Character in Java?

I need to know what is the difference between char and Character in Java because when I was making a java program, the char worked while the Character didn't work.

Answer

char is a primitive type that represents a single 16 bit Unicode character while Character is a wrapper class that allows us to use char primitive concept in OOP-kind of way.

Example for char,

char ch = 'a';

Example of Character,

Character.toUpperCase(ch);

It converts 'a' to 'A'