Created
January 29, 2023 12:36
-
-
Save pjastr/c230f3785474d42ba796438de6eee94a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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