似乎对象存的是引用,String存的是对象。String真的很神奇。。。 package com.yoara.first; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class RefeTest { public static void main(String[] args){ List l = new ArrayList(); objectT t = new objectT(); Map m = new HashMap(); t.setShow("abc"); l.add(t); m.put("t", t); t.setShow("abcd"); String s = "abc"; l.add(s); m.put("s", s); s="abcd"; System.out.println("------String------"); System.out.println("String:"+s); System.out.println("list:"+l.get(1)); System.out.println("map:"+m.get("s")); System.out.println("------Object------"); System.out.println("Object:"+t.getShow()); System.out.println("list:"+l.get(0)); System.out.println("map:"+m.get("t")); } } class objectT{ private String show; public String getShow() { return show; } public void setShow(String show) { this.show = show; } public String toString(){ return this.getShow(); } } 输出: ------String------ String:abcd list:abc map:abc ------Object------ Object:abcd list:abcd map:abcd