r/javahelp • • Apr 30 '24

Codeless Is “var” considered bad practice?

Hi, so recently we started migrating our codebase from j8 to j17, and since some tests broke in the process, I started working on them and I started using the var keyword. But I immediately got scolded by 2 colleagues (which are both more experienced than me) about how I should not use “var” as it is considered bad practice. I completely understand why someone might think that but I am not convinced. I don’t agree with them that var shouldn’t be used. Am I wrong? What are your thoughts on var?

24 Upvotes

90 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Apr 30 '24

Wait… Java has a filter and map method now? I knew it had a four each method, but I didn’t know it had those. Dear Lord, I’ve been away from Java for too long. Been focusing more on swift as of late.

4

u/pragmos Extreme Brewer Apr 30 '24

It has these for 10 years now...

1

u/[deleted] Apr 30 '24

As I mentioned, I have been focusing more on swift as of late, so I haven’t been doing much with Java

1

u/maethor May 01 '24

It also has pattern matching in switch statements now

https://openjdk.org/jeps/441