Well, of course, the program compiles. Heck, it even does what it's supposed to. You will soon learn, or may have already figured out, though, that a good program goes beyond just working. When you write a piece of code, you will want to ask yourself "How can I make this not only function, but be as reusable, modular, readable, and useful to anyone else as possible?" This is exactly the point of concepts like methods.
Let's take a look at another example: