Error ArrayIndexOutOfBoundsException on android : <p>i create login and register </p>

<p>build and run working but after register filed name  if use put name surname  it working can register but if i put onlu name no have surname don't work error </p>

<pre><code>String name = nameField.getText().toString().trim();

            if (email != null &amp;&amp; email.length() == 0 &amp;&amp; !android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches()) {

                emailField.setError(getString(R.string.com_parse_ui_no_email_toast));
            } else if (name != null &amp;&amp; name.length() == 0 &amp;&amp; config.isParseSignupNameFieldEnabled()) {

                nameField.setError(getString(R.string.com_parse_ui_no_name_toast));

            } else if (dateCheck == null) {

                mBirthday.setError(getString(R.string.signup_user_date));

            } else if (password.length() == 0) {

                passwordField.setError(getString(R.string.com_parse_ui_no_password_toast));
            } else if (password.length() &lt; minPasswordLength) {

                passwordField.setError(getResources().getQuantityString(R.plurals.com_parse_ui_password_too_short_toast, minPasswordLength, minPasswordLength));

            } else if (gender == null){

                showToast(getString(R.string.gender_missing));
            } else {

                String[] parts = name.split(" ");
                String firstName = parts[0];
                String lastName = parts[1];

                String username = (lastName+firstName).toLowerCase().trim().replaceAll(" ", "");

                User user = ParseObject.create(User.class);
</code></pre>
