What do I return if the return type of a method is Void? (Not void!)

前端 未结 6 1098
忘掉有多难
忘掉有多难 2020-12-07 12:12

Due to the use of Generics in Java I ended up in having to implement a function having Void as return type:

public Void doSomething() {
    //..         


        
6条回答
  •  感情败类
    2020-12-07 12:23

    There's no way to instantiate a Void, so the only thing you can return is null.

提交回复
热议问题