0Pricing
Java Academy · Lesson

The char Primitive

Characters and Unicode.

What Is a char?

A char is a Java primitive that holds a single character, like a letter, digit, or symbol.

You write a char value between single quotes: 'A', '7', or '?'. Double quotes make a String instead, so "A" is not a char.

char grade = 'A';
char symbol = '#';

Printing a char

You can store a char in a variable and print it just like any other value.

Here a complete program declares a char and prints it. Notice the single quotes around the letter.

public class Main {
    public static void main(String[] args) {
        char first = 'J';
        System.out.println(first);
    }
}

All lessons in this course

  1. The char Primitive
  2. Character Helper Methods
  3. Looping Over Characters
  4. Counting and Filtering Chars
← Back to Java Academy