Thursday, June 11, 2009

Java methods and declared return type

Guess the output:

May seem straight forward to Java Geeks.

I thought this would give compile time error. Later on realized the output is

This is funny

Moral: It is possible for a method to have a declared return type and yet contain no return statements.