前言:==和equals这个两个东西,经常放在一块做比较,下面我也给出一个简单的例子,对他俩进行一个简单的比较,先看例子,然后在看结论。(实验环境:win7+jdk7)

1:==和equals简单比较的实例代码如下

public class BooleanTestMain {
public static void main(String [] args){
Boolean _Boolean1 = true;
Boolean _Boolean2 = true;
Boolean _Boolean3 = new Boolean(true);
Boolean _Boolean4 = new Boolean(true); //输入对象的hashCode和identityHashCode,当对应的类没有重写hashCode()方法时,hashCode和identityHashCode是一致的
System.out.println("_Boolean1.hashCode() is : "+_Boolean1.hashCode()+" System.identityHashCode(_Boolean1) is : "+ System.identityHashCode(_Boolean1));
System.out.println("_Boolean2.hashCode() is : "+_Boolean2.hashCode()+" System.identityHashCode(_Boolean2) is : "+ System.identityHashCode(_Boolean2));
System.out.println("_Boolean3.hashCode() is : "+_Boolean3.hashCode()+" System.identityHashCode(_Boolean3) is : "+ System.identityHashCode(_Boolean3));
System.out.println("_Boolean4.hashCode() is : "+_Boolean4.hashCode()+" System.identityHashCode(_Boolean4) is : "+ System.identityHashCode(_Boolean4)); //==比较的是对象引用地址值
System.out.println("_Boolean1==_Boolean2 is : "+(_Boolean1==_Boolean2));
System.out.println("_Boolean3==_Boolean4 is : "+(_Boolean3==_Boolean4));
System.out.println("_Boolean1==_Boolean3 is : "+(_Boolean1==_Boolean3)); //equals比较的是对象的值,如果对象没有重写equals的话,其作用和==一样,因为Object类的equals也是通过==来比较的
System.out.println("_Boolean1.equals(_Boolean2) is : "+(_Boolean1.equals(_Boolean2)));
System.out.println("_Boolean3.equals(_Boolean4) is : "+(_Boolean3.equals(_Boolean4)));
System.out.println("_Boolean1.equals(_Boolean3) is : "+(_Boolean1.equals(_Boolean3))); }
}

上例运行的结果如下:

"C:\Program Files\Java\jdk1.7.0_71\bin\java" -Didea.launcher.port=7532 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.7.0_71\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\jfxrt.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\rt.jar;D:\workspace_test\hello-world\out\production\hello-world;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.3\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain com.jd.test.equ.BooleanTestMain
_Boolean1.hashCode() is : 1231 System.identityHashCode(_Boolean1) is : 1969344019
_Boolean2.hashCode() is : 1231 System.identityHashCode(_Boolean2) is : 1969344019
_Boolean3.hashCode() is : 1231 System.identityHashCode(_Boolean3) is : 1746959769
_Boolean4.hashCode() is : 1231 System.identityHashCode(_Boolean4) is : 756415799
_Boolean1==_Boolean2 is : true
_Boolean3==_Boolean4 is : false
_Boolean1==_Boolean3 is : false
_Boolean1.equals(_Boolean2) is : true
_Boolean3.equals(_Boolean4) is : true
_Boolean1.equals(_Boolean3) is : true Process finished with exit code 0

2:Boolean类的部分源码如下所示,重写了Object的hashCode()和equals()方法

    /**
* Returns a hash code for this {@code Boolean} object.
*
* @return the integer {@code 1231} if this object represents
* {@code true}; returns the integer {@code 1237} if this
* object represents {@code false}.
*/
public int hashCode() {
return value ? 1231 : 1237;
} /**
* Returns {@code true} if and only if the argument is not
* {@code null} and is a {@code Boolean} object that
* represents the same {@code boolean} value as this object.
*
* @param obj the object to compare with.
* @return {@code true} if the Boolean objects represent the
* same value; {@code false} otherwise.
*/
public boolean equals(Object obj) {
if (obj instanceof Boolean) {
return value == ((Boolean)obj).booleanValue();
}
return false;
}

3:Object类的equals()方法的源码如下所示,也是通过==来比较的

    /**
* Indicates whether some other object is "equal to" this one.
* <p>
* The {@code equals} method implements an equivalence relation
* on non-null object references:
* <ul>
* <li>It is <i>reflexive</i>: for any non-null reference value
* {@code x}, {@code x.equals(x)} should return
* {@code true}.
* <li>It is <i>symmetric</i>: for any non-null reference values
* {@code x} and {@code y}, {@code x.equals(y)}
* should return {@code true} if and only if
* {@code y.equals(x)} returns {@code true}.
* <li>It is <i>transitive</i>: for any non-null reference values
* {@code x}, {@code y}, and {@code z}, if
* {@code x.equals(y)} returns {@code true} and
* {@code y.equals(z)} returns {@code true}, then
* {@code x.equals(z)} should return {@code true}.
* <li>It is <i>consistent</i>: for any non-null reference values
* {@code x} and {@code y}, multiple invocations of
* {@code x.equals(y)} consistently return {@code true}
* or consistently return {@code false}, provided no
* information used in {@code equals} comparisons on the
* objects is modified.
* <li>For any non-null reference value {@code x},
* {@code x.equals(null)} should return {@code false}.
* </ul>
* <p>
* The {@code equals} method for class {@code Object} implements
* the most discriminating possible equivalence relation on objects;
* that is, for any non-null reference values {@code x} and
* {@code y}, this method returns {@code true} if and only
* if {@code x} and {@code y} refer to the same object
* ({@code x == y} has the value {@code true}).
* <p>
* Note that it is generally necessary to override the {@code hashCode}
* method whenever this method is overridden, so as to maintain the
* general contract for the {@code hashCode} method, which states
* that equal objects must have equal hash codes.
*
* @param obj the reference object with which to compare.
* @return {@code true} if this object is the same as the obj
* argument; {@code false} otherwise.
* @see #hashCode()
* @see java.util.HashMap
*/
public boolean equals(Object obj) {
return (this == obj);
}

4:为了认清==比较的本质,我又多实验了一把,如下所示

public class EquStringTestMain {
public static void main(String[]args){
String _String1 = "godtrue";
String _String2 = "godtrue";
System.out.println("_String1 value is : "+_String1+"\n_String2 value is : "+_String2);
System.out.println("_String1 identityHashCode is :"+System.identityHashCode(_String1)+"\n_String2 identityHashCode is :"+System.identityHashCode(_String2));
System.out.println("_String1==_String2 is : "+(_String1==_String2)+"\n"); String _String3 = new String("godtrue");
String _String4 = new String("godtrue");
System.out.println("_String3 value is : "+_String3+"\n_String4 value is : "+_String4);
System.out.println("_String3 identityHashCode is :"+System.identityHashCode(_String3)+"\n_String4 identityHashCode is :"+System.identityHashCode(_String4));
System.out.println("_String3==_String4 is : "+(_String3==_String4)+"\n"); String _String5 = _String1;
String _String6 = _String1;
System.out.println("_String5 value is : "+_String5+"\n_String6 value is : "+_String6);
System.out.println("_String5 identityHashCode is :"+System.identityHashCode(_String5)+"\n_String6 identityHashCode is :"+System.identityHashCode(_String6));
System.out.println("_String5==_String6 is : "+(_String5==_String6)+"\n"); String _String7 = _String3;
String _String8 = _String3;
System.out.println("_String7 value is : "+_String7+"\n_String8 value is : "+_String8);
System.out.println("_String7 identityHashCode is :"+System.identityHashCode(_String7)+"\n_String8 identityHashCode is :"+System.identityHashCode(_String8));
System.out.println("_String7==_String8 is : "+(_String7==_String8)+"\n"); String _String9 = _String1;
String _String0 = _String3;
System.out.println("_String9 value is : "+_String9+"\n_String0 value is : "+_String0);
System.out.println("_String9 identityHashCode is :"+System.identityHashCode(_String9)+"\n_String0 identityHashCode is :"+System.identityHashCode(_String0));
System.out.println("_String9==_String0 is : "+(_String9==_String0)+"\n");
}
}

上例运行的结果,如下所示(每次运行identityHashCode都不同的哟):

"C:\Program Files\Java\jdk1.7.0_71\bin\java" -Didea.launcher.port=7534 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.7.0_71\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\jfxrt.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\rt.jar;D:\workspace_test\hello-world\out\production\hello-world;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.3\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain com.jd.test.equ.EquStringTestMain
_String1 value is : godtrue
_String2 value is : godtrue
_String1 identityHashCode is :1748462787
_String2 identityHashCode is :1748462787
_String1==_String2 is : true _String3 value is : godtrue
_String4 value is : godtrue
_String3 identityHashCode is :247835561
_String4 identityHashCode is :1401482194
_String3==_String4 is : false _String5 value is : godtrue
_String6 value is : godtrue
_String5 identityHashCode is :1748462787
_String6 identityHashCode is :1748462787
_String5==_String6 is : true _String7 value is : godtrue
_String8 value is : godtrue
_String7 identityHashCode is :247835561
_String8 identityHashCode is :247835561
_String7==_String8 is : true _String9 value is : godtrue
_String0 value is : godtrue
_String9 identityHashCode is :1748462787
_String0 identityHashCode is :247835561
_String9==_String0 is : false

5:String类相对特殊一点,再来一个栗子尝尝

public class EquTestMain {
public static void main(String[]args){
int int1 = 9;
int int2 = 9;
System.out.println("int1 value is : "+int1+"\nint2 value is : "+int2);
System.out.println("int1 identityHashCode is :"+System.identityHashCode(int1)+"\nint2 identityHashCode is :"+System.identityHashCode(int2));
System.out.println("int1==int2 is : "+(int1==int2)+"\n"); Integer _Integer1 = 9;
Integer _Integer2 = 9;
System.out.println("_Integer1 value is : "+_Integer1+"\n_Integer2 value is : "+_Integer2);
System.out.println("_Integer1 identityHashCode is :"+System.identityHashCode(_Integer1)+"\n_Integer2 identityHashCode is :"+System.identityHashCode(_Integer2));
System.out.println("_Integer1==_Integer2 is : "+(_Integer1==_Integer2)+"\n"); Integer _Integer3 = new Integer(9);
Integer _Integer4 = new Integer(9);
System.out.println("_Integer3 value is : "+_Integer3+"\n_Integer4 value is : "+_Integer4);
System.out.println("_Integer3 identityHashCode is :"+System.identityHashCode(_Integer3)+"\n_Integer4 identityHashCode is :"+System.identityHashCode(_Integer4));
System.out.println("_Integer3==_Integer4 is : "+(_Integer3==_Integer4)+"\n"); Integer _Integer5 = int1;
Integer _Integer6 = int1;
System.out.println("_Integer5 value is : "+_Integer5+"\n_Integer6 value is : "+_Integer6);
System.out.println("_Integer5 identityHashCode is :"+System.identityHashCode(_Integer5)+"\n_Integer6 identityHashCode is :"+System.identityHashCode(_Integer6));
System.out.println("_Integer5==_Integer6 is : "+(_Integer5==_Integer6)+"\n"); Integer _Integer7 = _Integer1;
Integer _Integer8 = _Integer1;
System.out.println("_Integer7 value is : "+_Integer7+"\n_Integer8 value is : "+_Integer8);
System.out.println("_Integer7 identityHashCode is :"+System.identityHashCode(_Integer7)+"\n_Integer8 identityHashCode is :"+System.identityHashCode(_Integer8));
System.out.println("_Integer7==_Integer8 is : "+(_Integer7==_Integer8)+"\n"); Integer _Integer9 = _Integer3;
Integer _Integer0 = _Integer3;
System.out.println("_Integer9 value is : "+_Integer9+"\n_Integer0 value is : "+_Integer0);
System.out.println("_Integer9 identityHashCode is :"+System.identityHashCode(_Integer9)+"\n_Integer0 identityHashCode is :"+System.identityHashCode(_Integer0));
System.out.println("_Integer9==_Integer0 is : "+(_Integer9==_Integer0)+"\n");
}
}

上例运行的结果,如下所示(每次运行identityHashCode都不同的哟):

"C:\Program Files\Java\jdk1.7.0_71\bin\java" -Didea.launcher.port=7536 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.7.0_71\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\jfxrt.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0_71\jre\lib\rt.jar;D:\workspace_test\hello-world\out\production\hello-world;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.3\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain com.jd.test.equ.EquTestMain
int1 value is : 9
int2 value is : 9
int1 identityHashCode is :1401482194
int2 identityHashCode is :1401482194
int1==int2 is : true _Integer1 value is : 9
_Integer2 value is : 9
_Integer1 identityHashCode is :1401482194
_Integer2 identityHashCode is :1401482194
_Integer1==_Integer2 is : true _Integer3 value is : 9
_Integer4 value is : 9
_Integer3 identityHashCode is :1110594262
_Integer4 identityHashCode is :1977385357
_Integer3==_Integer4 is : false _Integer5 value is : 9
_Integer6 value is : 9
_Integer5 identityHashCode is :1401482194
_Integer6 identityHashCode is :1401482194
_Integer5==_Integer6 is : true _Integer7 value is : 9
_Integer8 value is : 9
_Integer7 identityHashCode is :1401482194
_Integer8 identityHashCode is :1401482194
_Integer7==_Integer8 is : true _Integer9 value is : 9
_Integer0 value is : 9
_Integer9 identityHashCode is :1110594262
_Integer0 identityHashCode is :1110594262
_Integer9==_Integer0 is : true

6:如上的代码,如果看完了,也理解了,基本上结论也出来了。(建议先看下hashCode和identityHashCode 的关系

6-1:==是比较运算符,当是基本数据类型时,比较的是变量的值,当是其他类型的对象时,用它比较的是两个对象的引用地址值是否相等

6-2:equals是一个方法,如果对应的类没有重现Object类的equals()方法,则和==是一样的作用

6-3:identityHashCode更能间接的代表一个对象的引用地址值

6-4:如果一个类没有重写Object类的hashCode方法那么hashCode和identityHashCode是一致的

6-5:hashCode相等时使用==比较,不一定是true

6-6:identityHashCode相等时使用==比较,一定是true

6-7:hashCode相等时使用equals比较,也不一定是true(通常可认为是true,我们自己可以随便定义的)

6-8:我们通常关心的是对象值是否相当(一个值或者多个值),所以对象之间的比较一定要使用equals方法,而非==

7:参看博文如下(观点一致,只是解释的思路或者栗子不同)

Java ==和equals()的区别【详细版】

Java中equals和==的区别

What is the difference between == vs equals() in Java?

java:String使用equals和==比较的区别

java中equals和==的区别

浅谈Java中的equals和==

==和equals的简单比较的更多相关文章

  1. C#中 == 与 Equals的简单理解

    using System; using System.Collections.Generic; using System.Collections; using System.IO; using Sys ...

  2. C# ReferenceEquals(), static Equals(), instance Equals(), 和运算行符==之间的关系

    C#充许你同时创建值类型和引用类型.两个引用类型的变量在引用同一个对象时,它们是相等的,就像引用到对象的ID一样.两个值类型的变量在它们的类型和内容都是相同时,它们应该是相等的.这就是为什么相等测试要 ...

  3. Java中“==”、“compareTo()”和“equals()”的区别

    在比较两个对象或者数据大小的时候,经常会用到==.compareTo()和equals(),尤其是在接入了Comparable接口后重写compareTo方法等场景,所以我们来理一下这三个的区别. 1 ...

  4. 详解Java中==和equals()的区别

    众所周知,在 Java 编程中,程序员通常会使用==或equals()来简单的比较地址,内容是否相等.而这两者之间的使用区别,对于初学 Java 的同学来说可能会比较迷糊.我将根据下面的几段示例程序, ...

  5. C#性能优化实践

    性能主要指两个方面:内存消耗和执行速度.性能优化简而言之,就是在不影响系统运行正确性的前提下,使之运行地更快,完成特定功能所需的时间更短. 本文以.NET平台下的控件产品MultiRow为例,描述C# ...

  6. C#性能优化实践【转】

    性能主要指两个方面:内存消耗和执行速度.性能优化简而言之,就是在不影响系统运行正确性的前提下,使之运行地更快,完成特定功能所需的时间更短. 本文以.NET平台下的控件产品MultiRow为例,描述C# ...

  7. 部分转载[C#性能优化实践]

    全文出处:http://www.infoq.com/cn/articles/C-sharp-performance-optimization 1.性能 主要指两个方面:内存消耗和执行速度.性能优化简而 ...

  8. ArrayList——源码探究

    摘要 ArrayList 是Java中常用的一个集合类,其继承自AbstractList并实现了List 构造器 ArrayList 提供了三个构造器,分别是 含参构造器-1 // 含参构造器-1 / ...

  9. 务实java基础之集合总结

    Java 提供了容纳对象(或者对象的句柄)的多种方式.其中内建的类型是数组,此外, Java 的工具库提供了一些 "集合类",利用这些集合类,我们可以容纳乃至操纵自己的对象. 声明 ...

随机推荐

  1. 有用的java工具

    1.Jsoup html页面解析 2.FastJson java中json处理工具,类似于gson 3.jodd 类似于apache commons的一些常用工具集 4.Selenium IDE we ...

  2. JavaScript 从闭包可以做什么开始,将有助于理解闭包

    本文内容 函数内部访问全局变量 函数外部不能直接访问局部变量 函数外部访问局部变量 保护私有成员 持久性 模块化 抽象性 闭包是 JavaScript 的重要特性,非常强大,可用于执行复杂的计算,可并 ...

  3. 人生规划和GTD——"知"、"得"与"合"

    作为<小强升职记>的读书感悟,给我自己.作为分享,也送给或许需要的给你. 我不知道你是否真的需要.但我受Amy师姐等一众人的影响,已经爱上了分享.呵呵,话也可以倒过来说,其实分享也就是爱. ...

  4. 通示jQuery实例方法,未DOM对象添加多个方法

    <script type="text/javascript"> /* * 通示jQuery实例方法,未DOM对象添加多个方法 * 用按钮做多个事件的调用 */ (fun ...

  5. ZH奶酪:Git简明教程

    这里是原网站:https://try.github.io/levels/1/challenges/1 这篇博文就当是笔记+翻译吧. 几个名词相关 changes:变更 repository:仓库 st ...

  6. Cocon90.Db调用方法

    Cocon90.DB 使用说明 开源库:https://github.com/Cocon90/Cocon90.Db Sqlite位置:https://www.nuget.org/packages/Co ...

  7. canvas语法糖

  8. 使用hadoop eclipse plugin提交Job并添加多个第三方jar

    来自:http://heipark.iteye.com/blog/1171923 通过 "conf.set("tmpjars", jars);" 可以设置第三方 ...

  9. Python2.7.14安装和pip配置安装及虚拟环境搭建

    目录 前言 1 Python2.7.14安装 2 pip配置安装 3 虚拟环境安装   前言 今天在搭建阿里云服务器,需要安装Python相关环境,之前在本机都已经安装过两遍,今天又来安装一遍,安装具 ...

  10. JS密码校验规则前台验证(不能连续字符(如123、abc)连续3位或3位以上)(不能相同字符(如111、aaa)连续3位或3位以上)

    密码必须为8到16位且必须包含数字和字母 密码必须包含特殊字符[_&#%] 不能连续字符(如123.abc)连续3位或3位以上 不能相同字符(如111.aaa)连续3位或3位以上 /** * ...