Sorry still learning and new to code. I don’t know if the title is clear or not, I'm trying to get user last and first input digits, I followed some tutorial and changed it to what I need the problem is I get some numbers even if the Edit Text is empty. I don't know if there is another way or not I just followed some topic to get first and last digit. Here is my code .

```
EditText ca_code = findViewById(R.id.caps_code);
TextView txt_code_out = findViewById(R.id.out_code);
int mutli = 0;

String lst_code = String.valueOf(ca_code);
//char fst = lst_code.charAt(0);
//char snd = lst_code.charAt(1);
char lat = lst_code.charAt(lst_code.length() - 1);
txt_code_out.setText(String.valueOf((int) lat));

```

for this i get different output if i change `length() - 1` 
for `-1 = output = 125` and for `-2 =101 , -3=100, -4= 111, -5 =99`

**Then I changed the code little bit to** 

```
EditText capscode = findViewById(R.id.caps_code);
TextView txt_code_out = findViewById(R.id.out_code);

String lst_code = String.valueOf(capscode);
//char fst = lst_code.charAt(0);
//char snd = lst_code.charAt(1);
char lat = lst_code.charAt(lst_code.length() - 1);
txt_code_out.setText(String.valueOf(lat));

```

The output was `}edoc_spac/di:ppa 7 300,,,` for -1 to 20