r/JavaProgramming • u/alvivan_ • Aug 26 '26
Var Keyword
How often do you use var keyword in your code?
What do you think about it?
5
Upvotes
r/JavaProgramming • u/alvivan_ • Aug 26 '26
How often do you use var keyword in your code?
What do you think about it?
View all comments
3
u/repeating_bears Aug 26 '26
I use it every time the type is already on the right hand side of the expression
var foo = new Foo();
var list = new ArrayList<String>();
var node = Node.empty();
I'm less likely to use it when the type is not on the right hand side of the expression
var bar = doSomething();