import java.util.function.Function; public class Playground { public static void main (String[] args) { Object o = null; System.out.println(o);
when you do
toStringFunc.apply(o);
this is the same that
o.toString()
that's why you get a NullPointerException so, you must ensure that your Object is not null.
NullPointerException