Runtime:
package com.codeurjava.hashtable;
import java.util.*;
public class hashtable_put {
public static void main(String args[]) {
// ハッシュテーブルを作成します
Hashtable ht = new Hashtable();
// ピアを挿入します
ht.put(1, "A");
ht.put(2, "B");
ht.put(3, "C");
System.out.println("変更前のハッシュテーブル: "+ht);
// 2
String val_ret=(String)ht.put(2,"BB");
System.out.println("置き換えられた値: "+val_ret);
System.out.println("変更後のハッシュテーブル: "+ht);
}
}
ハッシュ テーブルの初期値: {3=C, 2=B, 1=A}
置換された値: B
新しいハッシュテーブル: {3=C, 2=BB, 1=A}
ht.replace(2,"B","BB");Ressources:
Please disable your ad blocker and refresh the window to use this website.