mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
增加判断数组是否有重复元素的方法
This commit is contained in:
parent
f7b59ac744
commit
f79e1e31fb
@ -673,4 +673,23 @@ public class ArrayUtilTest {
|
||||
Assert.assertTrue(ArrayUtil.isSorted(f, Integer::compareTo));
|
||||
Assert.assertFalse(ArrayUtil.isSorted(f, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasSameElementTest() {
|
||||
final Integer[] a = {1, 1};
|
||||
Assert.assertTrue(ArrayUtil.hasSameElement(a));
|
||||
|
||||
final String[] b = {"a", "b", "c"};
|
||||
Assert.assertFalse(ArrayUtil.hasSameElement(b));
|
||||
|
||||
final Object[] c = new Object[]{"1", "2", 2, 4D};
|
||||
Assert.assertFalse(ArrayUtil.hasSameElement(c));
|
||||
|
||||
final Object[] d = new Object[]{"1", "2", "2", 4D};
|
||||
Assert.assertTrue(ArrayUtil.hasSameElement(d));
|
||||
|
||||
final Object[] e = new Object[]{"1", 2, 2, 4D};
|
||||
Assert.assertTrue(ArrayUtil.hasSameElement(e));
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user