Java 数组、字符串、集合操作:查找、判断、求最大值
-
public static boolean ifContains(int[] arr, int value) { for (int i : arr) { if (i == value) { return true; } } return false; }
-
public static boolean isLength0(String str) { return str.length() == 0; }
-
public static boolean isContainsRepeat(List
list) { Set set = new HashSet<>(list); return set.size() != list.size(); } -
public static int getMax(int[] arr) { int max = arr[0]; for (int i = 1; i < arr.length; i++) { if (arr[i] > max) { max = arr[i]; } } return max; }
原文地址: https://www.cveoy.top/t/topic/omqo 著作权归作者所有。请勿转载和采集!