That would work for a boolean value, but length returns an int value. So, if (errormessage.length == 0) // array is empty