On Void return type

The correct keyword in Java is void, not Void (notice the use of lowercase at the beginning). Void (uppercase) is, according to the documentation:

The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the Java keyword void.


Void is a class like any other, so a function returning Void has to return a reference (such as null). In fact, Void is final and uninstantiable, which means that null is the only thing that a function returning Void could return.

Of course public void blah() {...} (with a lowercase v) doesn't have to return anything.

If you're wondering about possible uses for Void, see Uses for the Java Void Reference Type?


Void is the object "wrapper" for the void type. A return type of void doesn't return a return value but Void does. You can't use void or any primitive type in a generic.

Tags:

Java

Void