String is empty
<p>I'm trying to validate the the field name is empty, and it is working</p>

<pre><code>while(name.isEmpty()||!name.matches("^([A-Z*a-z]*(\\s))+[A-Z*a-z]*$"))
</code></pre>

<p>When I try to validate the field number when it is empty it is giving an error.</p>

<pre><code>while (number.charAt(0) != '0' || number.length() &lt; 4 || !number.matches("^[0-9]*") || number.isEmpty())

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
    at java.lang.String.charAt(Unknown Source)
</code></pre>
