JAVA hashCode和toString

JAVA hashCode和toString[编程语言教程]

import java.util.HashMap;

public class Test {

    public Test() {
        // TODO Auto-generated constructor stub
    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        Person person1 = new Person();
        Person person2 = new Person();

        person1.name = "furong";
        person1.age = 12;

        person2.name = "furong";
        person2.age = 12;

        HashMap<Person, String> map = new HashMap<Person, String>();
        map.put(person1, "person1");

        System.out.println(map.get(person2));

        System.out.println(person1);
    }

}
hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » JAVA hashCode和toString