r/learnjava • u/MrBucurN • Jul 11 '26
Hi everyone!
Hi everyone!
I’m 18 years old and currently learning Java. Instead of following tutorials only, I’m building a text-based RPG called Legends of Eldoria.
This is version 0.3 and I’d love to get feedback on:
- Code quality
- Project structure
- Story flow
- Ideas for future versions
13
Upvotes
View all comments
Show parent comment
1
u/AutoModerator Jul 11 '26
You seem to try to compare
Stringvalues with==or!=.This approach does not work reliably in Java as it does not actually compare the contents of the Strings. Since String is an object data type it should only be compared using
.equals(). For case insensitive comparison, use.equalsIgnoreCase().Java stores
Stringliterals in a string pool where it is guaranteed that the same literal is the same object (refers to the same object).Yet, any non-literal (e.g. keyboard input, string operations, etc.) does not go in the string pool and therefore
==, which only compares object identity (i.e. the exact same reference) cannot reliably work there. Hence, always use.equals(),.equalsIgnoreCase().See Help on how to compare
Stringvalues in the /r/javahelp wiki.Your post is still visible. There is no action you need to take.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.