Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use .equals() to compare two strings in Java #961

Merged
merged 1 commit into from
Nov 21, 2023
Merged

Conversation

selear
Copy link
Contributor

@selear selear commented Nov 21, 2023

Java代码中,字符串内容的比较需要使用equals方法,'=='比较的是两个对象的地址是否相等。

@krahets krahets changed the title Java代码中,字符串的比较需要使用equals方法,而不是'==' fix: Use .equals() to compare two strings in Java Nov 21, 2023
Copy link
Owner

@krahets krahets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

While not affecting correctness, comparing strings using == is certainly not standard.

@krahets krahets added bug Bug fixes code Code-related labels Nov 21, 2023
@krahets krahets merged commit 5b6fb34 into krahets:main Nov 21, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug fixes code Code-related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants