mirror of
https://github.com/krahets/hello-algo.git
synced 2026-02-09 05:44:13 +08:00
docs: add Japanese translate documents (#1812)
* docs: add Japanese documents (`ja/docs`) * docs: add Japanese documents (`ja/codes`) * docs: add Japanese documents * Remove pythontutor blocks in ja/ * Add an empty at the end of each markdown file. * Add the missing figures (use the English version temporarily). * Add index.md for Japanese version. * Add index.html for Japanese version. * Add missing index.assets * Fix backtracking_algorithm.md for Japanese version. * Add avatar_eltociear.jpg. Fix image links on the Japanese landing page. * Add the Japanese banner. --------- Co-authored-by: krahets <krahets@163.com>
This commit is contained in:
committed by
GitHub
parent
2487a27036
commit
954c45864b
52
ja/codes/java/chapter_hashing/hash_map.java
Normal file
52
ja/codes/java/chapter_hashing/hash_map.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* File: hash_map.java
|
||||
* Created Time: 2022-12-04
|
||||
* Author: krahets (krahets@163.com)
|
||||
*/
|
||||
|
||||
package chapter_hashing;
|
||||
|
||||
import java.util.*;
|
||||
import utils.*;
|
||||
|
||||
public class hash_map {
|
||||
public static void main(String[] args) {
|
||||
/* ハッシュテーブルを初期化 */
|
||||
Map<Integer, String> map = new HashMap<>();
|
||||
|
||||
/* 追加操作 */
|
||||
// ハッシュテーブルにキー値ペア (key, value) を追加
|
||||
map.put(12836, "Ha");
|
||||
map.put(15937, "Luo");
|
||||
map.put(16750, "Suan");
|
||||
map.put(13276, "Fa");
|
||||
map.put(10583, "Ya");
|
||||
System.out.println("\n追加後、ハッシュテーブルは\nKey -> Value");
|
||||
PrintUtil.printHashMap(map);
|
||||
|
||||
/* 検索操作 */
|
||||
// ハッシュテーブルにキーを入力し、値を取得
|
||||
String name = map.get(15937);
|
||||
System.out.println("\n学生番号 15937 を入力し、名前 " + name + " を見つけました");
|
||||
|
||||
/* 削除操作 */
|
||||
// ハッシュテーブルからキー値ペア (key, value) を削除
|
||||
map.remove(10583);
|
||||
System.out.println("\n10583 を削除後、ハッシュテーブルは\nKey -> Value");
|
||||
PrintUtil.printHashMap(map);
|
||||
|
||||
/* ハッシュテーブルの走査 */
|
||||
System.out.println("\nキー値ペアを走査 Key->Value");
|
||||
for (Map.Entry<Integer, String> kv : map.entrySet()) {
|
||||
System.out.println(kv.getKey() + " -> " + kv.getValue());
|
||||
}
|
||||
System.out.println("\nキーを個別に走査 Key");
|
||||
for (int key : map.keySet()) {
|
||||
System.out.println(key);
|
||||
}
|
||||
System.out.println("\n値を個別に走査 Value");
|
||||
for (String val : map.values()) {
|
||||
System.out.println(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user