java 数组去重

private static final Integer[] hours =
    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23};
List newHoursList = new ArrayList<>(Arrays.asList(hours));
String[] deleteHoursStr ={"1","2","3","4"};
Integer[] deleteHours = new Integer[deleteHoursStr.length];
for (int i = 0; i < deleteHoursStr.length; i++) {
  deleteHours[i] = Integer.parseInt(deleteHoursStr[i]);
}
newHoursList.removeAll(Arrays.asList(deleteHours));

你可能感兴趣的:(java后端)