isempty for arrays
arr = new int[0];
if (arr.length == 0) {
System.out.println("array is empty");
}
3.98
5
Object arr[] = new Object[10];
boolean empty = true;
for (int i=0; i<arr.length; i++) {
if (arr[i] != null) {
empty = false;
break;
}
}
Thank you!
5
0
4.5
4
Object arr[] = new Object[10];
boolean empty = true;
for (Object ob : arr) {
if (ob != null) {
empty = false;
break;
}
}
Thank you!
4
0
4
8
int arr[] = null;
if (arr == null) {
System.out.println("array is null");
}
Thank you!
8
0
Are there any code examples left?
New code examples in category Other