Converting between structurally compatible function types
boaznahum at gmail.com
Mon Feb 23 17:38:43 UTC 2015
Yes, but what if Function has method that accepts R instead of returning
Try Function<String, ?> instead.
On Mon, Feb 23, 2015 at 7:32 PM Millies, Sebastian <
Sebastian.Millies at softwareag.com> wrote:
> 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
> 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