=与equals的区别是什么?

liaozj158 2007-08-22 11:02:32
=与equals的区别?
...全文
136 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
killpoer3 2007-08-28
  • 打赏
  • 举报
回复
==是比较是否引用了同一个对象。
equals是比较内容是否相等。
比如:
String a = new String("hello");
String b = new String("hello");
a==b的结果就是FALSE。
a.equals(b)的结果就是true.
jybbh 2007-08-23
  • 打赏
  • 举报
回复
equals
Compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object.
只比较string
-------------
==
可以等两个对象
wx红杉树 2007-08-23
  • 打赏
  • 举报
回复
== 一般语言支持字符或字符串和数值的比较.
而equals一般只是字符或字符串的比较.

2,100

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧