Your First Roblox Script
Your First Java Program
Java is strict (in a good way). You write a class, add main, print a line, and you’ve made a program.
What you’ll learn here
Get your first Java win fast, then build the basics: variables, decisions, and loops. The runner below is safe and beginner-focused.
Lesson: Hello, Java
This example prints one line. That’s the “first win”.
What each part means
Start point
class Main is the container. main is the start button.
Printing
System.out.println writes a line to the output.
Kid concepts (simple words)
If you’re new, read this first. It makes the code less scary.
- Program = a list of instructions.
- main = the start button of your program.
- println = “say this in the Output”.
- Quotes
"like this"= text. - Number
123= math stuff. - Brackets
{ }= a code room. What’s inside belongs together. - Bug = not a failure. It’s a clue.
Tiny challenges
- Change the message to your name.
- Add one more line:
System.out.println("I did it!"); - Try a score:
System.out.println("Score: " + 10);
More lessons (still beginner-friendly)
These are the next building blocks. Read them in order, then try the mini challenges.
Variables (store stuff)
Example: int coins = 10; and String name = "Alex";
Loops (repeat work)
Example: print “Count: 1” up to “Count: 5”.
If statements (make choices)
int age = 17;
if (age >= 18) {
System.out.println("Adult");
} else {
System.out.println("Not adult yet");
}
Common errors (normal stuff)
- Missing ; at the end of a line.
- Quotes mismatch like
"Hello(needs closing quote). - Brackets mismatch one
{without a matching}. - Wrong file/class name in real Java:
Main.javashould matchclass Main.
Mini challenges (blog-style homework)
- Print a 3-line “about me” card.
- Print 1 to 5 using a loop.
- Print “Win” if score is 10 or more.
This runner focuses on output only. For real projects, run Java with javac and java in a terminal or IDE.
Comments
Post a Comment