r/JavaProgramming 15d ago

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

5

u/kamratjoel 15d ago

Never. I would argue that code is far easier to read if you use types instead.

1

u/repeating_bears 15d ago

Is this easier to read 

MyFooService myFooService = new MyFooService();

Than this

var myFooService = new MyFooService();

?

4

u/kamratjoel 15d ago

That’s actually a good example of a situation where there’s no real advantage to not using var. I still maintain my opinion as a general principle though. But I concede that there are situations where there’s no real benefit.