Java Magazine, May/June 2018
ORACLE COM JAVAMAGAZINE MAY JUNE 2018 64 java 10 e printStackTrace can be refactored as follows in Java 10 var path Paths get src web log try var lines Files lines path var warningCount lines filter line line contains WARNING count System out println Found warningCount warnings in the log file catch IOException e e printStackTrace Each expression in this code still has a static type that is the declared type of a value as follows The local variable path is of type Path The variable lines is of type Stream String The variable warningCount is of type long This means that assigning a value of a different type will fail For example the reassignment in the following code will produce a compilation error var warningCount 5 warningCount 6 Error incompatible types java lang String cannot be converted to int warningCount 6
You must have JavaScript enabled to view digital editions.