Is there anything I can put in X, to make the follow work:
Object o = (void) X;
void is notionally a primitive. (though most would disagree it is even that I suspect) You cannot cast an object to it.
The closest you can come to this is an InvocationHandler can return null
for a void method and a void method invoke()ed via reflection will return null
.
Java is not C++. In Java, void is not a type, it is a placeholder that means "no return value".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With