Lesson content
Read, practise, then check your understanding
Java is case-sensitive. Source is organized into packages and types; executable statements live inside methods, constructors, or initialization blocks. A public top-level class normally matches its filename. Braces form scopes, statements usually end with semicolons, and //, /* */, and /** */ introduce line, block, and Javadoc comments.
A structured program
package learning.basics;
public final class Greeter {
private Greeter() {}
static String greeting(String name) {
return "Hello, " + name;
}
public static void main(String[] args) {
System.out.println(greeting("Mira"));
}
}
main is the conventional entry point. public makes it callable by the launcher, static means no receiver object is required, and void means no result. Identifiers may contain Unicode letters but clear conventional names are preferable. Use UpperCamelCase for types, lowerCamelCase for variables/methods, and UPPER_SNAKE_CASE for constants. Keep one responsibility per type and compile frequently with warnings enabled.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.