Here primitive 'x' is boxed for method test,Ī character preceded by a backslash (\) is an escape sequence and has a special meaning to the compiler. This feature is called autoboxing or unboxing, if the conversion goes the other way. For example, if you pass a primitive char into a method that expects an object, the compiler automatically converts the char to a Character for you. The Java compiler will also create a Character object for you under some circumstances. You can create a Character object with the Character constructor − The Character class offers a number of useful class (i.e., static) methods for manipulating characters. In order to achieve this, Java provides wrapper class Character for primitive data type char. However in development, we come across situations where we need to use objects instead of primitive data types. Unicode for uppercase Greek omega characterĬhar charArray =
Normally, when we work with characters, we use primitive data types char.