Your code compiles because it's syntax is correct. However as already mention

Java Tutorials - Defining Methods