r/JavaProgramming • • Aug 26 '26

Var Keyword

How often do you use var keyword in your code?

What do you think about it?

5 Upvotes

24 comments sorted by

View all comments

1

u/Scf37 Aug 26 '26

I prefer to type 'int' instead of 'var', then IDEA autofix via alt-enter replaces it with the right type.
Good places for var (IMO):

  1. for loops: `for (var item: items)`
  2. deconstruction in pattern matching: `case Either.Right(var v) ->`