Saturday, February 17, 2007

What does a void return value mean? Which class is being returned?

You've probably heard of this method :-

public static void main(String args[])
before. It's invoked by the JVM when starting a Java application. Have you ever wondered why it didn't have a return statement at the end of the method? After all, don't all methods return a value?

It's possible, and actually quite common, to not return a value. If you're not going to return a value, however, you must mark your method as void. This tells the compiler there's no need to enforce a return value.


www.referjava.com

No comments: