hanif s hanif s - 1 month ago 16
Android Question

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

I am new to java. Am unable to check for null. Could you enlighten me on this?
I have string array which has no elements.

I tried this code

String[] k = new String[3];

Answer Source

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 -