由于使用了 Java的类型擦除,我不得不实现一个函数,返回类型为 Void:
public Void doSomething() {
//...
}
编译器要求我返回 什么的。现在我只是返回 null,但我想知道,如果这是良好的编码实践..。
我问的是关于 V的,不是 翻译的。类 Void,没有的保留关键字 void。
I've also tried Void.class, void, Void.TYPE, new Void(), no return at all, but all that doesn't work at all. (For more or less obvious reasons) (See 这个答案 for details)
Void,我应该返回什么呢?Void类的一般用途是什么?