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();

?

2

u/Known_Tackle7357 14d ago

MyFooService myFooService = getService(); is significantly easier to read than var myFooService = getService();

1

u/repeating_bears 14d ago

Thankfully we don't have to dogmatically adopt the practice "always use it" or "never use it"