I want to create a list from Java Functions. But When I try to add a function to functions list, it says;
Non-static variable cannot be referenced from a static context
I don't get which method is static. Is there any idea?
My Main class:
public void createFunctionList() {
List<Function> functions = new ArrayList<>();
functions.add(Product::getInfo);
}
My product class:
public class Product
{
public Info getInfo() {
return info;
}
}
Product::getInfoyou make a reference to the function getInfo in the class Product. And thus without using an instance. So java is expecting getInfo to be static