Java
Working with strings
A practical reference with examples you can run.
Introduction
Strings represent text. Text can include spaces, digits, or punctuation. A character position is an index; a substring is a selected part of the text. Keep the original value if later steps still need it.
Syntax & example
public class Main {
public static void main(String[] args) {
String greeting = "hello, developer";
System.out.println(greeting.toUpperCase());
}
}Expected output
HELLO, DEVELOPER
Common mistakes
- Using a variable before assigning a value to it.
- Mixing text and numbers without converting deliberately.
- Skipping an empty input or a boundary value when testing.
Practice
Convert a greeting to uppercase.
Main.javaYour ideas, in code.
Loading your editor…
Run your code to see the output here.
Ready to buildUTF-86 lines