GCGrowCarrer

Strings

Locked

Lesson 3 of 60 · Syntax · Easy

Finish these first:Variables and Primitive Types →Or pass the tests below to unlock it now.

1

The big idea

A String holds text in Java — such as a word, a name, or a full sentence. Notice two small Java rules for strings: the type String starts with a capital S, and text always uses double quotes "...": You can join two strings with +, or check how many letters are inside a string with .length().

Think of it like this: Think of a `String` like a name tag: double quotes mark where the text starts and ends.
Key words (tap to learn):
2

Read the lesson

A String holds text in Java — such as a word, a name, or a full sentence.

Notice two small Java rules for strings: the type String starts with a capital S, and text always uses double quotes "...":

String city = "Tokyo";
String name = "Maya";
String note = "Welcome!";

You can join two strings with +, or check how many letters are inside a string with .length().

3

Quick check

In Java, how do you write a text variable named city set to "Tokyo"?

4

Your challenge

1 sample test, 1 hidden

Inside Solution, create a String variable named greeting holding "Hello" (type String greeting = "Hello";).

Stuck? Get a hint (free)
More learning tools(compare languages, visual guide, related lessons)

Compare with another language

Similar to javascript.strings (86% overlap). UTF-8 string manipulation: template literals in JS, std::string in C++, immutable strings in Go, &str/String in Rust.

Visual walkthrough

A diagram, a step-by-step animation, and short captions for Strings.

Mastery0%