Ler 3 ultimos caracteres

Olá pessoal, estou pesando o dia todo e estou com problema, tenho 2 string que quero pegar apenas os 3 ultimos numeros e atribuir para outra variavel

private String teste1 = “user_adm”;
private String teste2 = “sud_user”;

como faço para pegar apenas as 3 ultimas ficando

adm e user ?

String substr = teste1.substring(teste1.length() - 3)
String substr2 = teste2.substring(teste2.length() - 3)

[quote=alexmonassa]String substr = teste1.substring(teste1.length() - 3)
String substr2 = teste2.substring(teste2.length() - 3)[/quote]

opa era isso mesmo valeu, eu estava fazendo de uma forma diferente a qual dava um outro retorno

Mas e é isso que realmente queres?
É que segundo os teus exemplos, querias os caracteres depois do _ que não são necessariamente os três últimos (user tem 4 letras e não 3)

String substr = teste1.substring(teste1.lastIndexOf("_")+1); String substr2 = teste2.substring(teste1.lastIndexOf("_")+1);