Skip to content

Instantly share code, notes, and snippets.

@pjastr
Created January 29, 2023 12:36
Show Gist options
  • Select an option

  • Save pjastr/c230f3785474d42ba796438de6eee94a to your computer and use it in GitHub Desktop.

Select an option

Save pjastr/c230f3785474d42ba796438de6eee94a to your computer and use it in GitHub Desktop.
import java.time.LocalDate;
public class Main {
public static void main(String[] args) {
Integer[] intArray1 = {1, 2, 3};
Integer[] intArray2 = {};
LocalDate[] dateArray1 = {LocalDate.of(2020, 1, 1), LocalDate.of(2021, 1, 1)};
LocalDate[] dateArray2 = {};
System.out.println(ArrayUtil.isEmpty(intArray1)); // false
System.out.println(ArrayUtil.isEmpty(intArray2)); // true
System.out.println(ArrayUtil.isEmpty(dateArray1)); // false
System.out.println(ArrayUtil.isEmpty(dateArray2)); // true
}
}
class ArrayUtil {
public static <T extends Comparable<T>> boolean isEmpty(T[] array) {
return array.length == 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment