数组工具类 org.apache.commons.lang.ArrayUtils

/1.ArrayUtils.isEmpty(strs):判断数组是否为空, 不为空返回false, 为空true/
ArrayUtils.isEmpty(new String[]{“21”,”是”});//结果是false
ArrayUtils.isEmpty(new String[]{“”});//结果是false
ArrayUtils.isEmpty(new String[]{null});//结果是false
ArrayUtils.isEmpty(new String[]{});//结果是true
/2.ArrayUtils.isNotEmpty(strs):判断数组是否不为空,不为空返回true,为空false/
ArrayUtils.isNotEmpty(new String[]{“21”,”是”});//结果是true
ArrayUtils.isNotEmpty(new String[]{“”});//结果是true
ArrayUtils.isNotEmpty(new String[]{});//结果是false
/3.ArrayUtils.isSameLength(strs,strs2):判断两个数组长度是否相等,长度相等返回true,否则返回false。相比较的两个数组类型必须相同/
ArrayUtils.isSameLength(new String[]{“21”,”是”},new String[]{“21”,”是”});//返回false
/4.ArrayUtils.isSameType(strs,strs2):判断两个数组的类型是否相同,相同返回true,否则返回false/
ArrayUtils.isSameType(new String[]{“21”,”是”},newInteger[]{3});
/5.ArrayUtils.isEquals(strs,strs2)判断两个数组是否相等/
ArrayUtils.isEquals(strs,strs);//结果是true
/6.ArrayUtils.toString()将一个数组转换成String,用于打印/
ArrayUtils.toString(new String[]{“21”,”是”});//结果是:{21,是}
/7.ArrayUtils.clone赋值(克隆)数组/ Object[]s=ArrayUtils.clone(newObject[]{“33”,”yy”});
/8.ArrayUtils.subarray截取子数组:根据起始索引startIndexInclusive到结束索引startIndexInclusive/
Object[]s1=ArrayUtils.subarray(newObject[]{“33”,”yy”,”uu”},0,1);//结果是返回数组:[33]
Object[]s2=ArrayUtils.subarray(newObject[]{“33”,”yy”,”uu”},0,2);//结果是返回数组:[33,yy]
/9.ArrayUtils.indexOf查询某个object在数组中的位置,可是指定起始搜索位置/
intindex=ArrayUtils.indexOf(newObject[]{“33”,”yy”,”uu”},”uu”);//结果是2
intindex1=ArrayUtils.indexOf(newObject[]{“33”,”yy”,”uu”},”uu”,2);//结果是2
intindex3=ArrayUtils.indexOf(newObject[]{“33”,”yy”,”uu”},”uu”,3);//结果是-1
/10.ArrayUtils.lastIndexOf反向查询某个object在数组中的位置,可以指定起始搜索位置/
intindex11=ArrayUtils.lastIndexOf(newObject[]{“33”,”yy”,”uu”},”33”);//结果是0
intindex22=ArrayUtils.lastIndexOf(newObject[]{“33”,”yy”,”uu”},”33”,2);
/11.ArrayUtils.contains查询某个object是否在数组中/ ArrayUtils.contains(new String[]{“1”, “2”, “3”}, “11”);
/12.ArrayUtils.reverse反转数组/ ArrayUtils.reverse(new String[]{“22”,”yy”});//结果是:{“yy”,”22”}
/13.ArrayUtils.add添加一object到数组/ String[] t={“22”,”yy”};
String[] gg=(String[])ArrayUtils.add(t,”jj”);//{“22”,”yy”,”jj”}
/14.ArrayUtils.addAll合并两个数组/ String[]ggo=(String[])ArrayUtils.addAll(new String[]{“22”,”yy”},new String[]{“jj”});//结果是:[22,yy,jj]
ArrayUtils.addAll(new String[]{“22”,”yy”},new String[]{“jj”, “jj”}); //结果是:[22,yy,jj,jj]
/15.ArrayUtils.remove删除数组某个位置的元素/ String[]gg4=(String[])ArrayUtils.remove(new String[]{“22”,”yy”},1);
/16.ArrayUtils.removeElement删除数组中某个对象/ String[]ggpp=(String[])ArrayUtils.removeElement(new String[]{“22”,”yy”},”yy”);

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
commons-lang3.3.1.jar、Apache Commons包中的一个,包含了一些数据类型工具类,是java.lang.*的扩展。必须使用的jar包。为JRE5.0+的更好的版本所提供 Jar文件包含的类: META-INF/MANIFEST.MFMETA-INF/LICENSE.txtMETA-INF/NOTICE.txtorg.apache.commons.lang.ArrayUtils.class org.apache.commons.lang.BitField.class org.apache.commons.lang.BooleanUtils.class org.apache.commons.lang.CharEncoding.class org.apache.commons.lang.CharRange.class org.apache.commons.lang.CharSet.class org.apache.commons.lang.CharSetUtils.class org.apache.commons.lang.CharUtils.class org.apache.commons.lang.ClassUtils.class org.apache.commons.lang.Entities$ArrayEntityMap.class org.apache.commons.lang.Entities$BinaryEntityMap.class org.apache.commons.lang.Entities$EntityMap.class org.apache.commons.lang.Entities$HashEntityMap.class org.apache.commons.lang.Entities$LookupEntityMap.class org.apache.commons.lang.Entities$MapIntMap.class org.apache.commons.lang.Entities$PrimitiveEntityMap.class org.apache.commons.lang.Entities$TreeEntityMap.class org.apache.commons.lang.Entities.class org.apache.commons.lang.IllegalClassException.class org.apache.commons.lang.IncompleteArgumentException.class org.apache.commons.lang.IntHashMap$Entry.class org.apache.commons.lang.IntHashMap.class org.apache.commons.lang.LocaleUtils.class org.apache.commons.lang.NotImplementedException.class org.apache.commons.lang.NullArgumentException.class org.apache.commons.lang.NumberRange.class org.apache.commons.lang.NumberUtils.class org.apache.commons.lang.ObjectUtils$Null.class org.apache.commons.lang.ObjectUtils.class org.apache.commons.lang.RandomStringUtils.class org.apache.commons.lang.SerializationException.class org.apache.commons.lang.SerializationUtils.class org.apache.commons.lang.StringEscapeUtils.class org.apache.commons.lang.StringUtils.class org.apache.commons.lang.SystemUtils.class org.apache.commons.lang.UnhandledException.class org.apache.commons.lang.Validate.class org.apache.commons.lang.WordUtils.class org.apache.commons.lang.builder.CompareToBuilder.class org.apache.commons.lang.builder.EqualsBuilder.class org.apache.commons.lang.builder.HashCodeBuilder.class org.apache.commons.lang.builder.ReflectionToStringBuilder$1.class org.apache.commons.lang.builder.ReflectionToStringBuilder.class org.apache.commons.lang.builder.StandardToStringStyle.class org.apache.commons.lang.builder.ToStringBuilder.class org.apache.commons.lang.builder.ToStringStyle$DefaultToStringStyle.class org.apache.commons.lang.builder.ToStringStyle$MultiLineToStringStyle.class org.apache.commons.lang.builder.ToStringStyle$NoFieldNameToStringStyle.class org.apache.commons.lang.builder.ToStringStyle$ShortPrefixToStringStyle.class org.apache.commons.lang.builder.ToStringStyle$SimpleToStringStyle.class org.apache.commons.lang.builder.ToStringStyle.class org.apache.commons.lang.enum.Enum$Entry.class org.apache.commons.lang.enum.Enum.class org.apache.commons.lang.enum.EnumUtils.class org.apache.commons.lang.enum.ValuedEnum.class org.apache.commons.lang.enums.Enum$Entry.class org.apache.commons.lang.enums.Enum.class org.apache.commons.lang.enums.EnumUtils.class org.apache.commons.lang.enums.ValuedEnum.class org.apache.commons.lang.exception.ExceptionUtils.class org.apache.commons.lang.exception.Nestable.class org.apache.commons.lang.exception.NestableDelegate.class org.apache.commons.lang.exception.NestableError.class org.apache.commons.lang.exception.NestableException.class org.apache.commons.lang.exception.NestableRuntimeException.class org.apache.commons.lang.math.DoubleRange.class org.apache.commons.lang.math.FloatRange.class org.apache.commons.lang.math.Fraction.class org.apache.commons.lang.math.IntRange.class org.apache.commons.lang.math.JVMRandom.class org.apache.commons.lang.math.LongRange.class org.apache.commons.lang.math.NumberRange.class org.apache.commons.lang.math.NumberUtils.class org.apache.commons.lang.math.RandomUtils.class org.apache.commons.lang.math.Range.class org.apache.commons.lang.mutable.Mutable.class org.apache.commons.lang.mutable.MutableBoolean.class org.apache.commons.lang.mutable.MutableByte.class org.apache.commons.lang.mutable.MutableDouble.class org.apache.commons.lang.mutable.MutableFloat.class org.apache.commons.lang.mutable.MutableInt.class org.apache.commons.lang.mutable.MutableLong.class org.apache.commons.lang.mutable.MutableObject.class org.apache.commons.lang.mutable.MutableShort.class org.apache.commons.lang.text.CompositeFormat.class org.apache.commons.lang.text.StrBuilder$StrBuilderReader.class org.apache.commons.lang.text.StrBuilder$StrBuilderTokenizer.class org.apache.commons.lang.text.StrBuilder$StrBuilderWriter.class org.apache.commons.lang.text.StrBuilder.class org.apache.commons.lang.text.StrLookup$MapStrLookup.class org.apache.commons.lang.text.StrLookup.class org.apache.commons.lang.text.StrMatcher$CharMatcher.class org.apache.commons.lang.text.StrMatcher$CharSetMatcher.class org.apache.commons.lang.text.StrMatcher$NoMatcher.class org.apache.commons.lang.text.StrMatcher$StringMatcher.class org.apache.commons.lang.text.StrMatcher$TrimMatcher.class org.apache.commons.lang.text.StrMatcher.class org.apache.commons.lang.text.StrSubstitutor.class org.apache.commons.lang.text.StrTokenizer.class org.apache.commons.lang.time.DateFormatUtils.class org.apache.commons.lang.time.DateUtils$DateIterator.class org.apache.commons.lang.time.DateUtils.class org.apache.commons.lang.time.DurationFormatUtils$Token.class org.apache.commons.lang.time.DurationFormatUtils.class org.apache.commons.lang.time.FastDateFormat$CharacterLiteral.class org.apache.commons.lang.time.FastDateFormat$NumberRule.class org.apache.commons.lang.time.FastDateFormat$PaddedNumberField.class org.apache.commons.lang.time.FastDateFormat$Pair.class org.apache.commons.lang.time.FastDateFormat$Rule.class org.apache.commons.lang.time.FastDateFormat$StringLiteral.class org.apache.commons.lang.time.FastDateFormat$TextField.class org.apache.commons.lang.time.FastDateFormat$TimeZoneDisplayKey.class org.apache.commons.lang.time.FastDateFormat$TimeZoneNameRule.class org.apache.commons.lang.time.FastDateFormat$TimeZoneNumberRule.class org.apache.commons.lang.time.FastDateFormat$TwelveHourField.class org.apache.commons.lang.time.FastDateFormat$TwentyFourHourField.class org.apache.commons.lang.time.FastDateFormat$TwoDigitMonthField.class org.apache.commons.lang.time.FastDateFormat$TwoDigitNumberField.class org.apache.commons.lang.time.FastDateFormat$TwoDigitYearField.class org.apache.commons.lang.time.FastDateFormat$UnpaddedMonthField.class org.apache.commons.lang.time.FastDateFormat$UnpaddedNumberField.class org.apache.commons.lang.time.FastDateFormat.class org.apache.commons.lang.time.StopWatch.class

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值