Why doesn't for-each method in java not throw an exception when a Function type argument is passed instead of Consumer?