so I do have code like this:
public ConsumerTestClass(Consumer<String> consumer) {
}
public static void printString(String text) {
System.out.println(text);
}
And from the method of other class, I would like to create object of ConsumerTestClass
:
new ConsumerTestClass(/*passing consumer here*/);
And as a consumer I would like to pass ConsumerTestClass::printString
, but to be able to do that I need to pass argument as well, so it looks like that: (text) -> ConsumerTestClass.printString(text)
. And my question is... Is it only option to pass Consumer, or method which is accepting one argument and returning no results?