首先我们看下下面代码及输出和String重写equals和hashcode的源码: package com.zzy.test; public class Test6 { public static void main(String[] args) { String s1="aaa"; String s2="aaa"; String s3=new String("aaa"); String s4="bbb"; System.out.println(s1.equals(s2)); System.