Difference between object oriented object based programming language

How can one prove that array is not null but empty ?

Answer : Check its null value first then check length of the array. Please see example below:

public class ArrayNullCheck {

    public static void main(String[] args) {
	String arrayCheck[] = new String[2];
	arrayCheck[0] = "Java";
	arrayCheck[1] = "Honk";

	if (null != arrayCheck && arrayCheck.length != 0) {
	    System.out.println(arrayCheck.length);
	}

    }

}

 

Leave a Reply

Your email address will not be published. Required fields are marked *