JAVA中==和EQUALS的区别
1、 ==操作符
==操作符专门用来比较变量的值是否相同。
基本数据类型:比较的是他们的值是否相同。
引用数据类型:比较的是他们的内存地址是否同一地址。
引用类型对象变量其实是一个引用,它们的值是指向对象所在的内存地址,而不是对象本身。
2、 equals方法
equals方法常用来比较对象的内容是否相同。
Java当中所有的类都是继承于Object这个超类的,在Object类中定义的equals方法:
public boolean equals(Object obj) {return (this == obj);}
未重写equals方法的类:Object中的equals方法实际使用的也是==操作符,比较的是他们的内存地址是否同一地址。
重写了equals方法的类:实现该类自己的equals方法比较逻辑(一般是比较对象的内容是否相同)。比如:
String:比较字符串内容,内容相同这相同;
Integer:比较对应的基本数据类型int的值是否相同(==操作符)。
We are a gavgle of voluntteers andd opening a neww shheme in our community. Your web site provided us with helpful info tto work on. Youu haave perrformed aan imjpressive activity and our entire neighborhhood ill be thankful to you. xnxx
Thanks for sharing
:mrgreen: :mrgreen: :mrgreen:
Aldactazide from acne meds rx