java之hashCode

package com.simope.myTest;

import java.util.HashMap;
import java.util.Map;

public class Test20151022 {
    
    public static void main(String[] args) {
        
        int count = 0;
        
        String str = "hello world";
        String myStr = "hello world";
        
        Map<String, Object> map = new HashMap<String, Object>();
        Map<String, Object> myMap = new HashMap<String, Object>();
        
        map.put("name", "zhangsan");
        map.put("age", "12");
        map.put("sex", "man");
        
        myMap.put("name", "zhangsan");
        myMap.put("age", "13");
        myMap.put("sex", "women");
        
        
        System.out.println((++count) + ": " + str.hashCode());
        
        System.out.println((++count) + ": " + myStr.hashCode());
        
        System.out.println("############################################");
        
        System.out.println((++count) + ": " + map.get("name").hashCode());
        
        System.out.println((++count) + ": " + map.get("age").hashCode());
        
        System.out.println((++count) + ": " + map.get("sex").hashCode());
        
        System.out.println("############################################");
        
        System.out.println((++count) + ": " + myMap.get("name").hashCode());
        
        System.out.println((++count) + ": " + myMap.get("age").hashCode());
        
        System.out.println((++count) + ": " + myMap.get("sex").hashCode());
        
        System.out.println("############################################");
    
        System.out.println((++count) + ": " + str.getClass());
        
        System.out.println((++count) + ": " + myMap.getClass());
        
        System.out.println("############################################");
        
        
        
        
    }

}
原文地址:https://www.cnblogs.com/JimLy-BUG/p/5026672.html