Help Username in Jtextfield

-2

I need to generate a "nickname" based on 3 jtextfield, which takes the first two letters of each text ... for example

Juan
Perez
Gonzalez

and let the nick name be

JUPEGO
    
asked by Juan Pablo 18.04.2018 в 20:41
source

1 answer

2

Once you retrieve the content of each jtextfield you must substring each variable. finally it gives you a toUpperCase.

String nombre = "Juan";
String paterno = "Perez";
String materno = "Gonzalez";        
String nickname = (nombre.substring(0, 2) + paterno.substring(0, 2) + materno.substring(0, 2)).toUpperCase();
    
answered by 18.04.2018 / 21:22
source