Converting between structurally compatible function types
Millies, Sebastian
Sebastian.Millies at softwareag.com
Mon Feb 23 17:31:56 UTC 2015
Hello there,
I have a very basic question: why does the following not compile:
Function<String,Integer> f = s -> 1;
Function<String,Object> g = f;
After all, I would expect that anywhere where a function from String to arbitrary objects is required, I can supply a function to integers in particular.
I guess Java just sees the names are different, and that’s it?
How do I best convert between the two types?
n Sebastian
Software AG – Sitz/Registered office: Uhlandstraße 12, 64297 Darmstadt, Germany – Registergericht/Commercial register: Darmstadt HRB 1562 - Vorstand/Management Board: Karl-Heinz Streibich (Vorsitzender/Chairman), Eric Duffaut, Dr. Wolfram Jost, Arnd Zinnhardt; - Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Dr. Andreas Bereczky - http://www.softwareag.com
More information about the lambda-dev
mailing list