September 2019
Intermediate to advanced
816 pages
18h 47m
English
Well, var is not a silver bullet, and this problem will highlight this once again. The following snippet of code can be written using explicit types or var without losing information:
// using explicit typesMemoryCacheImageInputStream is = new MemoryCacheImageInputStream(...);JavaCompiler jc = ToolProvider.getSystemJavaCompiler();StandardJavaFileManager fm = compiler.getStandardFileManager(...);
So, migrating the preceding snippet of code to var will result in the following code (the variables names have been chosen by visually inspecting the called names from the right-hand side):
// using varvar inputStream = new MemoryCacheImageInputStream(...);var ...