Concept Explanation
This lesson introduces how a Java program is structured and how execution starts from the main method. Instead of treating the file as magic, you will read a tiny program, run it, and connect each part of the code to what the JVM actually needs in order to execute it. The goal is to make the first Java file feel understandable, not memorized. By the end, you should be comfortable identifying the class, the entry point, and the line that produces output.
Where to Put the Code
- Define color and position variables at the top.
- Create shape drawing or placement logic in the middle.
- Render output (print, canvas, SVG, or styled block) at the end.
Command Reference
- Point to the entry point of the program and explain why Java starts there.
- Run the starter code, change the printed message, and confirm the new output.
- Describe what the class name and file name relationship looks like in a simple Java project.
- Check your understanding by explaining what each line does in plain English.
Step-by-step Guide
- Read the file from top to bottom and identify the class declaration and the main method.
- Run the program once without changing anything and note the exact output.
- Replace the sample name or message with your own value and run the code again.
- Explain in one sentence why the JVM needs a main method in this example.
- Finish with a quick check: does the program compile, run, and print what you expected?
Practice Exercises
- Change the example so it prints two separate lines of output.
- Create a second version that greets a user by name using a String variable.
- Write a short explanation of what would break if the main method were removed.
Coding Challenges
- Create a tiny welcome program that prints a title, a learner name, and a status message in a clear order.
- Rewrite the code so the output is still correct but the variable names are more meaningful.
Mini Practice Tasks
- Rename the variable to make its purpose clearer.
- Change the output text so it sounds like a real program message.
- Write one sentence summarizing what part of the file Java executes first.
Common Mistake
Mixing x and y axes or using wrong coordinate origin causes shapes to appear in unexpected places.
Real-life Mini Challenge
Draw one square, one triangle, and one circle, then move X marker 2 steps right and 1 step down.