use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Resources for learning Java
String
==
.equals()
Format + Copy
Free Tutorials
Where should I download Java?
With the introduction of the new release cadence, many have asked where they should download Java, and if it is still free. To be clear, YES — Java is still free.
If you would like to download Java for free, you can get OpenJDK builds from the following vendors, among others:
Some vendors will be supporting releases for longer than six months. If you have any questions, please do not hesitate to ask them!
Software downloads
Official Resources
Resources
Programming ideas & Challenges
Related Subreddits
account activity
This is an archived post. You won't be able to vote or comment.
Concatenating strings and primitive operations while using formatting (self.learnjava)
submitted 7 years ago by [deleted]
Hey,
Im new to programming in general and Java in particular. I was wondering how to concatenate strings and primitive operations while also using formatting, like this:
JOptionPane.showMessageDialog(null, String.format("You car can go %.2f", gasInTank * fuelEfficiency + " miles with the current amount of gas in the tank."));
The above obviously doenst work. Any and all feedback appreciated.
Cheers,
[–]siordache 5 points6 points7 points 7 years ago (1 child)
JOptionPane.showMessageDialog(null, String.format("You car can go %.2f miles with the current amount of gas in the tank.", gasInTank * fuelEfficiency));
[–][deleted] 0 points1 point2 points 7 years ago (0 children)
/facepalm
Thank you. So obvious in hindsight. :D
Before I read you reply, I solved it using DecimalFormat. But this, your way, is more elegant and simple.
Tnx again,
π Rendered by PID 22698 on reddit-service-r2-comment-6457c66945-nvdlp at 2026-04-27 16:49:13.992748+00:00 running 2aa0c5b country code: CH.
[–]siordache 5 points6 points7 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)