RE:还有数组的equals()方法问题?

pvii 2004-07-19 11:55:54
既然数组是对象那么equals()方法是如何实现的?
如果我想实现数组的equals()方法该如何做呢?
...全文
138 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
shine333 2004-07-19
  • 打赏
  • 举报
回复
你想实现数组的equals方法,如果是指重载的话,是不可能的,
因为你没法public class Object[] { }

要比较两个数组是否相同,可以使用java.util.Arrays中的equals方法
shine333 2004-07-19
  • 打赏
  • 举报
回复
数组的equals就是Object的equals方法,也就是==
lixiang823517 2004-07-19
  • 打赏
  • 举报
回复
equals(object[] a1,object[] a2) 返回一个boolean
figoren 2004-07-19
  • 打赏
  • 举报
回复
equals
public static boolean equals(int[] a,int[] a2)
Returns true if the two specified arrays of ints are equal to one another. Two arrays are considered equal if both arrays contain the same number of elements, and all corresponding pairs of elements in the two arrays are equal. In other words, two arrays are equal if they contain the same elements in the same order. Also, two array references are considered equal if both are null.


Parameters:
a - one array to be tested for equality.
a2 - the other array to be tested for equality.
Returns:
true if the two arrays are equal
pvii 2004-07-19
  • 打赏
  • 举报
回复
equals比内容,==比引用,数组的equals()如何实现

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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