Unit 01 · lesson

Your First Java 25 Program Without the Ceremony

For years, many Java beginners met the language through a line like this:

public static void main(String[] args) {

That line is real Java, but it asks a beginner to accept several concepts before they have any reason to understand them: access modifiers, static members, arrays, parameters, classes, and the program entry point.

Java 25 gives us a better on-ramp.

Start with behavior

Open the official Java Playground at https://dev.java/playground/ and run:

void main() {
    IO.println("Hello, Java.");
}

Read it literally:

  • void says this method does not return a value;
  • main is the launchable entry method;
  • { and } define its body;
  • IO.println(...) produces a line of output;
  • the quoted value is a String.

You do not need to memorize the complete formal model yet. You need to be able to connect each piece of syntax to observable behavior.

Compact does not mean fake

This is not Robotnix inventing a simplified Java dialect. Java 25 supports compact source files and instance main methods as part of the language.

That matters because we can grow this program instead of throwing it away later.

Add a method:

String greeting() {
    return "Welcome to Java 25";
}

void main() {
    IO.println(greeting());
}

The program now has two behaviors:

greeting() -> produces a String
main()     -> asks for that String and prints it

Later, when explicit classes become useful, the same method ideas move inside named classes. The learning path slopes upward instead of teleporting from "toy Java" to "real Java."

Syntax carries structure

Try these changes one at a time. Predict first.

Change A: remove the semicolon

IO.println("Hello")

What stage should reject the program?

Change B: change the string

IO.println("Hello, Robotnix.");

What should remain identical? What should change?

Change C: print two lines

void main() {
    IO.println("first");
    IO.println("second");
}

What is the execution order?

Change D: reverse the statements

Does Java infer that "first" should still appear first because of the English word? Of course not. Programs follow their defined control flow, not the programmer's story about them.

Build a tiny status report

Write a program that prints exactly four lines:

SYSTEM: java-course
UNIT: 1
STATUS: running
NEXT: trace execution

Do not paste four prewritten print statements and stop. First write the expected output as your specification. Then implement it. Run it. Compare actual output against the specification character by character.

Now introduce one deliberate defect. Examples:

  • misspell one label;
  • reverse two lines;
  • remove punctuation;
  • break a string literal.

Classify the defect as compile-time or logic. Fix it and preserve the before/after evidence.

A first engineering habit

The important habit is not "make red text disappear." It is:

expected behavior
      |
      v
prediction
      |
      v
execution
      |
      v
observed behavior
      |
      v
compare and explain

That loop will survive every language feature in this course.

What to keep

Your evidence page should contain the expected four-line output, the final code, the observed output, the deliberate defect, its classification, and the smallest change that corrected it.

A perfect first attempt gives you less debugging evidence than a controlled mistake you can explain.