Your First Roblox Script

Your First Java Program: An Interactive Beginner Blog

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.

Goal: see output
Skill: read errors
Next: variables
Java starter illustration

Lesson: Hello, Java

Edit the code. Press Run. Change one thing at a time.
Runner: ready

This example prints one line. That’s the “first win”.

Ready.

      
Tip: change the text inside quotes and run again. If you see an error, read it slowly.

What each part means

Class and main illustration

Start point

class Main is the container. main is the start button.

Println illustration

Printing

System.out.println writes a line to the output.

If you only remember one thing: main is the start.

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 illustration

Variables (store stuff)

Example: int coins = 10; and String name = "Alex";

Loops illustration

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.java should match class 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

Popular posts from this blog

NEW YEAR countdown

LEGO Smart Brick (CES 2026): What’s New and Why It Matters

Networking Concepts (Basic → Intermediate) 1 Day Study Guide