Answers for "isempty for arrays"

0

isempty for arrays

arr = new int[0];
if (arr.length == 0) {
  System.out.println("array is empty");
}
Posted by: Guest on November-22-2020
0

isempty for arrays

Object arr[] = new Object[10];
boolean empty = true;
for (Object ob : arr) {
  if (ob != null) {
    empty = false;
    break;
  }
}
Posted by: Guest on November-22-2020
0

isempty for arrays

Object arr[] = new Object[10];
boolean empty = true;
for (int i=0; i<arr.length; i++) {
  if (arr[i] != null) {
    empty = false;
    break;
  }
}
Posted by: Guest on November-22-2020
0

isempty for arrays

int arr[] = null;
if (arr == null) {
  System.out.println("array is null");
}
Posted by: Guest on November-22-2020

Browse Popular Code Answers by Language