Create 387.md#15
Open
hiroki-horiguchi-dev wants to merge 1 commit into
Open
Conversation
nodchip
reviewed
May 14, 2026
| } | ||
|
|
||
| for (int i = 0; i < s.length(); i++) { | ||
| if (frequency.get(s.charAt(i)).equals(1)) { |
There was a problem hiding this comment.
if (frequency.get(s.charAt(i)) == 1) {と書いても、アンボクシングされるため、意図通り動くようです。
https://docs.oracle.com/javase/specs/jls/se17/html/jls-15.html#jls-15.21.1
If the operands of an equality operator are both of numeric type, or one is of numeric type and the other is convertible (§5.1.8) to numeric type, binary numeric promotion is performed on the operands (§5.6).
Owner
Author
There was a problem hiding this comment.
コメントありがとうございます!
等号演算子を使ったとき、片方がプリミティブであり、もう片方がアンボクシング可能ならアンボクシングされてから演算されるのですね。
Cluadeは Integer == Integer の比較になると言っていましたが、危うく嘘を信じ込むところでした。。
一次情報をもっと読み込むべきでした。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
387. First Unique Character in a Stringを解きました、レビューをお願いします