mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-09 03:02:35 +08:00
Retranslate the complete Japanese online edition from Chinese (#2008)
* Retranslate the complete Japanese online edition from Chinese * Fit Japanese homepage labels and localize heading permalinks * Point Japanese contribution instructions to the Japanese preview * Replace locale conditionals with multilingual UI tables
This commit is contained in:
@@ -11,40 +11,40 @@ import utils.*;
|
||||
|
||||
public class hash_map {
|
||||
public static void main(String[] args) {
|
||||
/* ハッシュテーブルを初期化 */
|
||||
/* ハッシュテーブルを初期化する */
|
||||
Map<Integer, String> map = new HashMap<>();
|
||||
|
||||
/* 追加操作 */
|
||||
// ハッシュテーブルにキーと値のペア (key, value) を追加
|
||||
map.put(12836, "シャオハー");
|
||||
map.put(15937, "シャオルオ");
|
||||
map.put(16750, "シャオスワン");
|
||||
map.put(13276, "シャオファー");
|
||||
map.put(10583, "シャオヤー");
|
||||
System.out.println("\n追加後のハッシュ表は\nKey -> Value");
|
||||
// ハッシュテーブルにキーと値のペア (key, value) を追加する
|
||||
map.put(12836, "小哈");
|
||||
map.put(15937, "小啰");
|
||||
map.put(16750, "小算");
|
||||
map.put(13276, "小法");
|
||||
map.put(10583, "小鸭");
|
||||
System.out.println("\n追加後のハッシュテーブル\nKey -> Value");
|
||||
PrintUtil.printHashMap(map);
|
||||
|
||||
/* 検索操作 */
|
||||
// キー key をハッシュテーブルに渡し、値 value を取得
|
||||
/* 取得操作 */
|
||||
// ハッシュテーブルにキー key を渡し、値 value を取得する
|
||||
String name = map.get(15937);
|
||||
System.out.println("\n学籍番号 15937 を入力すると、氏名 " + name);
|
||||
System.out.println("\n学生番号 15937 に対応する氏名は " + name);
|
||||
|
||||
/* 削除操作 */
|
||||
// ハッシュテーブルからキーと値のペア (key, value) を削除
|
||||
// ハッシュテーブルからキーと値のペア (key, value) を削除する
|
||||
map.remove(10583);
|
||||
System.out.println("\n10583 を削除すると、ハッシュ表は\nKey -> Value");
|
||||
System.out.println("\n10583 を削除した後のハッシュテーブル\nKey -> Value");
|
||||
PrintUtil.printHashMap(map);
|
||||
|
||||
/* ハッシュテーブルを走査 */
|
||||
System.out.println("\nキーと値の組 Key->Value を走査");
|
||||
/* ハッシュテーブルを走査する */
|
||||
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 のみを走査");
|
||||
System.out.println("\nキー Key だけを走査する");
|
||||
for (int key : map.keySet()) {
|
||||
System.out.println(key);
|
||||
}
|
||||
System.out.println("\n値 Value のみを走査");
|
||||
System.out.println("\n値 Value だけを走査する");
|
||||
for (String val : map.values()) {
|
||||
System.out.println(val);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user