Empty Check With String[] Array

Empty check with String[] array

To check if a string array is empty...

public boolean isEmptyStringArray(String [] array){
for(int i=0; i<array.length; i++){
return false;
return true;

Checking if String Array is filled or empty

You didn't have tried the obvious?

if (rule[0] == null) {

Checking for an empty string array

Beside the proposed using of Array#toString method, I suggest to use Array#join with an empty string as separator and then test the result. The advantage is, it works for an arbitrary count of elements inside of the array.

var bool = array.join('') ? 'not all empty string' : 'all empty string';

How to check for empty String array including empty elements

I think you will have to do it manually, perferrably using StringUtils.isNotBlank(str) instead of arrayUtils. So that you don't iterate twice over the array.

How to check String in array is empty or null?

Just a foreach loop on the array

static boolean hasEmpty(String[] values){
for(String elt : values)
return true;
return false;

If you want to add a not only whitespace string use

if (elt.isEmpty() || elt.isBlank()) {

how to check the string array is empty or null android?

Very precisely

if(k!=null && k.length>0){
System.out.println("Array is not initialized or empty");

k!=null would check array is not null. And StringArray#length>0 would return it is not empty[you can also trim before check length which discard white spaces].

Some related popular question -

  • What is null in java?
  • Avoiding “!= null” statements in Java?

How can I check JavaScript arrays for empty strings?

You have to check in through loop.

function checkArray(my_arr){
for(var i=0;i<my_arr.length;i++){
if(my_arr[i] === "")
return false;
return true;

How to check if an element in a string array is empty?

Have you tried the 'obvious':

if(correct[0] != null && correct[0].length() > 0) {
//it is not null and it is not empty

Check if String array element is null

if(dates[i] != null);

the extra ; causes the following block to always execute (regardless of the evaluation of the if statement), since it ends the if statement. Remove it.

Related Topics

Leave a reply