I want to return double type value in the given Primitive Functional Interface:
DoubleFunction<double> db1=(x)-> x+2;
System.out.println(db1.apply(23.6));
This gives me an error,but the below code is correct:
DoubleFunction<String> db1=(x)-> x +" is now a String";
System.out.println(db1.apply(23.6));
I want to know why the generic type should be String? Can anyone give me an example which returns int/double in Primitive Functional Interface?