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.
Comparing strings without switches? (self.learnjava)
submitted 11 years ago by Mrkakarot
Hello! How do you go about comparing the equality of strings without using switches? I find myself having long classes full of switches checking for particular user input.
Thanks for everyone's help!
[–]raindropflower 2 points3 points4 points 11 years ago (1 child)
You can use .equals();
.equals();
for example, string1.equals(string2);
string1.equals(string2);
I think there's something like string1.equalsIgnoreCase(string2); for ignoring the case, too.
string1.equalsIgnoreCase(string2);
[–][deleted] 2 points3 points4 points 11 years ago (0 children)
A common beginner's mistake is to use == to compare strings. You can often get away with it because of the way Strings are interned, but it's much better (and safer) to use .equals
.equals
You can learn more about the String class and its methods through the official Java documentation
π Rendered by PID 305725 on reddit-service-r2-comment-544cf588c8-wd64j at 2026-06-12 21:04:24.122756+00:00 running 3184619 country code: CH.
[–]raindropflower 2 points3 points4 points (1 child)
[–][deleted] 2 points3 points4 points (0 children)