Strings
LockedLesson 3 of 60 · Syntax · Easy
Finish these first:Variables and Primitive Types →Or pass the tests below to unlock it now.
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.
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().
Quick check
In Java, how do you write a text variable named city set to "Tokyo"?
Your challenge
Inside Solution, create a String variable named greeting holding "Hello" (type String greeting = "Hello";).
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.