Compilation error | Sololearn: Learn to code for FREE!


Compilation error I need help, anyone know how to fix it? I want to turn every letter into uppercase et some letters into numbers (A->4 ; E->3; O->0;...)

7/26/2019 9:33:34 AM

GreeFoss XD

2 Answers

New Answer


GreeFoss XD texte is a scanner object and it does not have a replace method. You should be doing like this String textenum = texte.nextLine(); System.out.println(textenum); textenum = textenum.replace("A", "4"); same for others


//with .toUpperCase(); public static void main(String[] args) { Scanner sc = new Scanner(; System.out.println("votre texte:"); String texte = sc.nextLine(); System.out.println(texte); System.out.println("________________________"); String textenum = texte.toUpperCase() .replace("A","4") .replace("E","3") .replace("I","1") .replace("T","7") .replace("O","0") .replace("B","8") .replace("S","5") .replace("G","6") .replace("Z","2"); System.out.println(textenum); } }