Comments document code functionality using //, /* */, and /** */ without affecting program execution, while preconditions and postconditions specify method contracts.
Imagine handing someone a thousand-piece jigsaw puzzle with no picture on the box.
That's what uncommented code feels like — technically all the pieces are there, but good luck figuring out what you're building.
Comments are the picture on the box.
They're messages you leave inside your code that Java completely ignores when running the program, but that humans desperately need when reading it.
In Java, you have three flavors: use `//` when you want a quick note on a single line, wrap longer explanations in `/* */` for a block of text, and reach for `/** */` when you're writing formal Javadoc documentation that can be turned into polished reference pages — the kind you've probably already seen when looking up how a method works.
But comments aren't just about explaining *what* code does.
Two of the most powerful things you can document are *preconditions* and *postconditions*.
A precondition is a promise the caller must keep before a method runs — like "this number must be positive" — and the method won't check for you.
A postcondition is what the method guarantees after it finishes, like "the list will be sorted" or "this returns the largest value." Think of preconditions as the rules for using a tool, and postconditions as the warranty for what it delivers.
Writing these down in comments transforms mysterious code into something any programmer — including future you — can trust and understand.