史家小学网站建设,怎么编程做一个小游戏,济南建设工程备案网站,华侨城网站建设原文网址#xff1a;Spring工具类--CollectionUtils的使用_IT利刃出鞘的博客-CSDN博客
简介
本文介绍Spring的CollectionUtils的使用。
CollectionUtils工具类的作用#xff1a;操作Collection#xff0c;比如#xff1a;List、Set。
判断
方法作用static boolean is…原文网址Spring工具类--CollectionUtils的使用_IT利刃出鞘的博客-CSDN博客
简介
本文介绍Spring的CollectionUtils的使用。
CollectionUtils工具类的作用操作Collection比如List、Set。
判断
方法作用static boolean isEmpty (Collection? collection) 判断集合是否为空。static boolean isEmpty(Map?,? map) 判断Map是否为空static boolean containsInstance ( Collection? collection, Object element )判断集合中是否包含某个对象static boolean contains ( Iterator? iterator, Object element )通过迭代器判断某个对象是否在集合中。static boolean containsAny ( Collection? source, Collection? candidates )判断集合中是否包含某些对象中的任意一个。static boolean hasUniqueObject (Collection? collection) 判断集合中的每个元素是否唯一。即集合中不存在重复元素。
向集合中添加
方法作用static E void mergeArrayIntoCollection ( Object array, CollectionE collection )将数组中的元素都添加到集合中。static K,V void mergePropertiesIntoMap ( Properties props, MapK,V map )将 Properties 中的键值对都添加到 Map 中
在集合中查找
方法作用static T T lastElement (ListT list) 返回 List 中最后一个元素。static T T lastElement (SetT set) 返回 Set 中最后一个元素。static E E findFirstMatch ( Collection? source, CollectionE candidates )返回 candidates 中第一个存在于 source 中的元素。static T T findValueOfType ( Collection? collection, ClassT type )返回集合中指定类型的元素。static Object findValueOfType ( Collection? collection, Class?[] types )返回集合中指定类型的元素。如果第一种类型未找到则查找第二种类型以此类推。static Class? findCommonElementType (Collection? collection) 返回集合中元素的类型