I have a problem in my programm, I want the user of my programm to write the file he wants to use and then with loops, depending on the word he typed, a file will be used. Butmy programm never enters in one loop and I don't know where the problem comes from.
Here is my code:
System.out.println("Nom du test case à lancer ? : ");
Scanner saisieUtilisateur = new Scanner(System.in);
//on rentre l'adresse du fichier texte :
String str = saisieUtilisateur.next();
System.out.println(str);
//Integer val = saisieUtilisateur.nextInt();
//System.out.println(val);
String chaine = "";
String File="";
int i=1;
//Choix du fichier a prendre en compte suivant le choix de l'utilisateur
if (str == "hello"){
File = "C:\\exempleANT\\helloWordTexte.txt";
System.out.println("dans la boucle 1");
}
else if(str == "bye"){
System.out.println("dans la boucle 2");
File = "C:\\exempleANT\\FichiersTestExempleHelloWord\\bye.txt";
}
else if(str == "fake"){
System.out.println("dans la boucle 3");
File = "C:\\exempleANT\\FichiersTestExempleHelloWord\\helloWordTexteFake.txt";
}
else {
System.out.println("ErreurTexte!");
System.out.println("dans la boucle 4");
}
And here is the result in the console when I run the programm and I type hello.
hello
hello
ErreurTexte!
dans la boucle 4