I built a simple app which contains one method,this app should check if the phone number which inserted by the user is valid.
so i did the the following steps:

1. Declar the edit text in the java file
2. Refer the variable to the variable in the xml file
3. Do get text and to string to this variable
4. Write the methoud that refer to the "phone" variable

declare(step 1):

```
private static EditText phone_et_c

```

refare(step 2):

```
phone_et_c=(EditText) findViewById(R.id.phone_et_c);

```

get text and to string(step 3):

```
String phone=phone_et_c.getText().toString();

```

and the mathoud is(step 4):

```
public static boolean isValid(String phone)
{
    if ((phone.length()==10)||(phone.charAt(0)==0&&phone.charAt(1)==5)){
        return true;
    }
    else
        return false;
}

```

my error was that:

> 
> 10-14 10:06:05.885 5140-5140/com.miara.yagel.maspera E/AndroidRuntime: FATAL EXCEPTION: main
>  Process: com.miara.yagel.maspera, PID: 5140
>  java.lang.StringIndexOutOfBoundsException: length=0; index=0
>  at java.lang.String.charAt(Native Method)
>  at com.miara.yagel.maspera.CreatUserActivity.isValid(CreatUserActivity.java:69)
>  at com.miara.yagel.maspera.CreatUserActivity$1.onClick(CreatUserActivity.java:56)
>  at android.view.View.performClick(View.java:6294)
>  at android.view.View$PerformClick.run(View.java:24770)
>  at android.os.Handler.handleCallback(Handler.java:790)
>  at android.os.Handler.dispatchMessage(Handler.java:99)
>  at android.os.Looper.loop(Looper.java:164)
>  at android.app.ActivityThread.main(ActivityThread.java:6494)
>  at java.lang.reflect.Method.invoke(Native Method)
>  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
>  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
> 
> 
> 

thanks!