user1357722 user1357722 - 2 years ago 75
Java Question

What is the difference between java.lang.Void and void?


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

  1. What is "uninstantiable" place holder class? When will
    be used? If the class is "uninstantiable", what use is it?

  2. What is difference between

Answer Source

The only point of Void is to hold Void.TYPE, which is sort of like void.class. If you have a reflective reference to a method that returns void, and you get its return type, it'll return Void.TYPE.

You cannot, and should not, use it for anything else.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download