【初心者】Java質問・相談スレッド73【大歓迎】
■ このスレッドは過去ログ倉庫に格納されています
0487デフォルトの名無しさん
2005/10/19(水) 17:04:52読みにくくて申し訳ありませんが、
public class MapTest {
public static void main(final String[] args) {
final Map sampleMapA = new HashMap();
final String[] sampleKeyA1 = new String[] { "hoge", "hoge" };
final String[] sampleKeyA2 = new String[] { "hoge", "hoge" };
final String valueA = "hogehoge";
sampleMapA.put(sampleKeyA1, valueA);
System.out.println("get by sampleKeyA1 : " + sampleMapA.get(sampleKeyA1)); // (1)
System.out.println("get by sampleKeyA2 : " + sampleMapA.get(sampleKeyA2)); // (2)
// 参考に String[] の代替に Map を使う
final Map sampleMapB = new HashMap();
final Map sampleKeyB1 = new HashMap();
sampleKeyB1.put("fuga", "fuga");
final Map sampleKeyB2 = new HashMap();
sampleKeyB2.put("fuga", "fuga");
final String valueB = "fugafuga";
sampleMapB.put(sampleKeyB1, valueB);
System.out.println("get by sampleKeyB1 : " + sampleMapB.get(sampleKeyB1)); // (3)
System.out.println("get by sampleKeyB2 : " + sampleMapB.get(sampleKeyB2)); // (4)
}
}
などとすると、(2) だけは値が取得できず null となりますが、
この場合 get(Object) の中では何と何が評価された結果取れないのでしょうか…?
■ このスレッドは過去ログ倉庫に格納されています