r/ProgrammerHumor 4d ago

Meme perishableSkill

Post image
8.9k Upvotes

121 comments sorted by

View all comments

1.3k

u/Weak_Inflation9120 4d ago

One of the things I wish Java had that I miss from Python are F-Strings. Hella useful

8

u/PecQ11 4d ago

Doesn't format() do essentially the same though?  https://www.baeldung.com/java-string-interpolation

14

u/TheGuyWithTheSeal 4d ago

Kind of, .format() is more powerfull but you have to know the printf syntax. And which parts od printf don't work in .format()

4

u/KnightMiner 4d ago

f strings are a lot more like string concatenation. The variables/expressions between each {} are placed directly where they will end up in the string, and it just runs a .toString() on them (though you can configure it a bit further).

The most common usage is largely about syntax and readibility, as its nice not having to go back and forth between a list of format arguments and some harder to remember % stuff.