Hello I am prepаring for ocp and can not understand why java compiler allows not save assignment? For example:
ExecutorService executorService = Executors.newSingleThreadExecutor();
Callable c = () -> 2;
Future<String> submit = executorService.submit(c);
System.out.println(submit.get().length());
Why compiler not enforce me add explicit cast:
Future<String> submit = (Future<String>) executorService.submit(c);
Can someone explain why cast is not required?