I don't understand why this doesn't work
Go to solution
Solved by zwirek2201,
First of all, for pasting code please use code tags. You can find them in the edit post bar marked by <> icon. It will make it easier for people to read the code and edit it if neede.
Now to your problem:
Instead of using s1 == "boy" use s1.equals("boy")
"==" operator checks whether references to s1 and "boy" are equal. ".equals" method checks actual contents.
You can read about it more here:
https://stackoverflow.com/questions/767372/java-string-equals-versus
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now