why var operation | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why var operation

26th Apr 2020, 7:41 AM
Ramya teja
Ramya teja - avatar
2 Answers
+ 1
As we know that in JavaScript we declare variable with var keyword and var keyword automatically understand data type according to value. So in latest version of Java we can also use var for any data type.
26th Apr 2020, 8:00 AM
A͢J
A͢J - avatar
0
For my daily coding work the most important benefit of var is, that it makes refactorings a lot easier. Renaming classes: When you rename a class you do not have to touch every single class where a variable of that type exists, when it was just the value of a property or method coming from another class. Changing return types: When you change the return type of a method not every usage has to be touched when it does not execute specific operations on the result which cannot be supported anymore. Besides the refactoring part, I personally like the readability it brings. When you declare multiple variables below each other all their names start at the same position.
28th Apr 2020, 7:07 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar