I am using the below code to create java.util.function Function> instance and use the return value of Function instance to pass it to the ExecutorService.submit() method.
However I get a "Symbol Not Found" exception. Please help
Below is the code snippet:
//Approach-1
Function<Integer, Callable<Integer>> doubleIt_1 = (index) -> {return () -> {return index * 2;};};
//Approach-2
Function<Integer, Callable<Integer>> doubleIt_2 = (index) -> () -> {return index * 2;};
//Approach 3
Function<Integer, Callable<Integer>> doubleIt_3 = (index) -> () -> index * 2;
//Use the "doubleIt" lambda function defined above to pass as a Lambda function to ExecutorService threadpool's submit method.
Function<Integer, Future<Integer>> task = (Integer index) -> pool.submit(doubleIt_1(index));
The compiler throws the error: java: cannot find symbol symbol: method doubleIt_1(java.lang.Integer) location: class declarative.L12LegacyToFunctionalInterface_4
Please help...