Void的源码如下。
Void和void的关系, Placeholder class for the Java keyword void.
Void 是 void 的占位符类。
/**
* Placeholder class for the Java keyword {@code void}.
*
* @since 1.1
*/
public final class Void {
/**
* The {@link Class} object that represents the primitive type {@code void}.
*/
public static final Class<Void> TYPE = lookupType();
// Note: Void.TYPE can't be set to "void.class", since *that* is
// defined to be "java.lang.Void.TYPE";
@SuppressWarnings("unchecked")
private static Class<Void> lookupType() {
try {
Method method = Runnable.class.getMethod("run", EmptyArray.CLASS);
return (Class<Void>) method.getReturnType();
} catch (Exception e) {
throw new AssertionError(e);
}
}
private Void() {
}
}