7 ms·
Once you get to Java 11+ you get `var`, so you can spell it `var me = new Person()`.
by svieira 6y ago
Once you get to Java 11+ you get `var`, so you can spell it `var me = new Person()`.
- mgkimsal 6y agoWas recently on a project that just migrated to java 11 (mid august of this year) from java 8. Someone has started to try to introduce 'var' and is getting push back from others. "it doesn't match current style" and "could be confusing" were some 'concerns'. When you're trying to do InternalFormatParserCustomForClientABCDEF customerFormatParser = new InternalFormatParserCustomForClientABCDEF(param1, param2); you really start to hit readability limits, and formatting things like going over nominal line lengths and such. var customerFormatParser = new InternalFormatParserCustomForClientABCDEF(param1, param2); is certainly easier on the eyes, and the compiler can still known and infer what type 'customerFormatParser' is.
- nkohari 6y agoYeah, the same debates happened in C# back when the 'var' keyword was introduced. People just fear change, but once they got hands-on experience they realized the value.
- metters 6y agoJust don't use it together with lombok.