Module 3: Operators, Expressions, and Strings
String Basics and Concatenation
Store text in strings and combine text with values to make output more useful.
Author
Java Learner Editorial Team
Reviewer
Technical review by Java Learner
Last reviewed
2026-04-16
Java version
Java 25 LTS
Learning goals
- Declare and print strings
- Concatenate strings with `+`
- Mix text with variables in readable output
What a string is: A String stores text such as names, messages, and labels. Strings use double quotes.
Concatenation: The + operator also joins strings together. This is called concatenation.
Mixing text and values: You can combine strings with numbers and booleans to build friendly output messages.
Why this matters: Most programs need readable output, prompts, labels, and messages, not just raw numbers.
Runnable examples
Join two pieces of text
public class Main {
public static void main(String[] args) {
String first = "Java";
String second = "Learner";
System.out.println(first + " " + second);
}
}Expected output
Java Learner
Combine text with a variable
public class Main {
public static void main(String[] args) {
int lessons = 4;
System.out.println("Completed lessons: " + lessons);
}
}Expected output
Completed lessons: 4
Common mistakes
Using single quotes for multi-character text
Strings use double quotes, like `"Hello"`.
Mini exercise
Create a string for your name and print `Hello, <name>`.
Summary
- Strings store text.
- The `+` operator can join strings together.
Next step
Once strings feel comfortable, use a few helpful string methods.
Sources used