请问以下代码返回的结果是什么?为什么?- package com.lesson13;
- import java.util.HashMap;
- public class HashCodeDemo {
- public static void main(String[] args) {
- HashMap hm = new HashMap();
- hm.put(new Person("张三", 20), "张三");
- System.out.println(hm.get(new Person("张三", 20)));
- }
- }
- class Person {
- private String name;
- private int age;
- Person(String name, int age) {
- this.name = name;
- this.age = age;
- }
- @Override
- public String toString() {
- return "姓名:" + this.name + "年龄:" + this.age;
- }
- }
复制代码 |