Domanda

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?

È stato utile?

Soluzione

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).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top