Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3a48e3f

Browse files
author
jsquared21
committed
Edit method MyHashMap.get(key) for efficiency
1 parent6fde7c4 commit3a48e3f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed
3 Bytes
Binary file not shown.

‎Exercise_27/Exercise_27_01/MyHashMap.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public V get(K key) {
9090
intindex =hash(key.hashCode());
9191

9292
while(table.get(index) !=null) {
93-
if (table.get(index).getKey() ==key) {
93+
if (table.get(index).getKey().equals(key)) {
9494
returntable.get(index).getValue();
9595
}
9696
index++;
@@ -120,7 +120,7 @@ public java.util.Set<K> keySet() {
120120
@Override/** Add an entry (key, value) into the map */
121121
publicVput(Kkey,Vvalue) {
122122
intindex =hash(key.hashCode());
123-
123+
124124
while (table.get(index) !=null) {
125125
// The key is already in the map
126126
if (table.get(index).getKey().equals(key)) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp