質問

I have a method which receives a Function<Void, Void> (A Guava Function, not a Java 8 Function):

public void foo(Function<Void, Void> algo) {

  algo.apply();  // <- Compile error. 

}

I have a compile error because algo.apply() takes a Void instance as argument but I don't know how to instantiate one.

What is the syntax for this use case?

役に立ちましたか?

解決

A Void instance is rather contradictory. Try passing null. If you don't get a NullPointerException then that's probably the correct thing to do.

(Else read the documentation if there is any).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top