Replace()
replace()
- String replace(char antigo_caracter, char novo_caracter): Devolve a cadea resultante de sustituir cada caracter antigo_caracter por novo_caracter.
class MetodoReplace { public static void main(String[] args) { String s = "Ola, que tal: postmaster@mail.com?"; //Reemprazar o caracter arroba polo caracter guion. System.out.println(s.replace('@','-')); } }
--ricardofc