java Arrays.equals()方法简介

您所在的位置:网站首页 远程控制别人电脑的方法有哪些软件 java Arrays.equals()方法简介

java Arrays.equals()方法简介

2024-07-09 10:33:02| 来源: 网络整理| 查看: 265

简介

java Arrays中定义了如下几种equals方法,用来对比判断数组是否相等

equals(boolean[], boolean[])equals(byte[], boolean[])equals(char[], boolean[])equals(double[], boolean[])equals(float[], boolean[])equals(short[], boolean[])equals(int[], boolean[])equals(long[], boolean[])equals(Object[], boolean[])

源码

每一个方法里的源码实现基本都差不多,我们看下equals(int[], boolean[])的源码实现

代码很简单,若两个数组的长度相等,且每一个位置的元素也相等,则认为这两个数组相等

/** * 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.

* * @param a one array to be tested for equality * @param a2 the other array to be tested for equality * @return true if the two arrays are equal */ public static boolean equals(int[] a, int[] a2) { if (a==a2) return true; if (a==null || a2==null) return false; int length = a.length; if (a2.length != length) return false; for (int i=0; i



【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


图片新闻

实验室药品柜的特性有哪些
实验室药品柜是实验室家具的重要组成部分之一,主要
小学科学实验中有哪些教学
计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
实验室各种仪器原理动图讲
1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
高中化学常见仪器及实验装
1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
微生物操作主要设备和器具
今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
浅谈通风柜使用基本常识
 众所周知,通风柜功能中最主要的就是排气功能。在

专题文章

    CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭