Menu
Coddy logo textTech

String

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

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

The String type is a special type that consists of multiple chars.

To initialize a string value in a variable, enclose it within double quotation marks:

String s1 = "This is a string";

In the above example, a string variable named s1 is initialized.

challenge icon

Challenge

Beginner

Store the string I am learning to code with Coddy! in a variable named coddy.

Be sure to store the exact string value with correct casing.

Cheat sheet

A char is a single character (e.g., 1, 6, %, b, p, ., T).

A String consists of multiple chars. Initialize a string by enclosing it in double quotation marks:

String s1 = "This is a string";

Try it yourself

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

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

All lessons in Fundamentals