What is Java char data type with example

The char data type in Java

The char Java is one of the primitive data types in Java.

The Java char data type:

  • Takes 16 bits or two bytes memory.
  • Is used to store any type of character value.
  • The minimum value of char variable is 0.
  • The maximum value is 65,535.

A char example

The example below declares and uses char data type variables. The char variable is assigned a value and then we will display it by using the System.out.println statement.

As you run code the output will be:


Experience this online

In the example, you can see a Java char variable is declared while the value can be assigned later or at the time of declaration.

Also see – The double data type | Integer in java | short type

Was this article helpful?

Related Articles

Leave A Comment?