Menu
Coddy logo textTech

char

Part of the Fundamentals section of Coddy's Java journey — lesson 8 of 73.

A char is a single character (For example: 1, 6, %, b, p, ., T, etc.)

The char type is a special type that consists of a single character.

To initialize a char value in a variable, enclose it within single quotation marks:

char c1 = 'h';

In the above example, a char variable named c1 is initialized.

challenge icon

Challenge

Beginner

Store the char C in a variable named initial.

Cheat sheet

A char is a single character (For example: 1, 6, %, b, p, ., T, etc.)

To initialize a char value in a variable, enclose it within single quotation marks:

char c1 = 'h';

Try it yourself

public class Main {
    public static void main(String[] args) {
        // Type your code below
        char initial = ?
        
        // Don't change the line below
        System.out.println("initial = '" + initial + "'");
    }
}
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals