Comparaison de string en Java

Résolu
Bonjour,

je voudrais savoir comment peux ton comparer deux string an JAVA pour savoir si la seconde string est présente dans la première..

merci
Configuration: Windows XP
Firefox 2.0.0.13

3 réponses

  1. salut,

    Il faut lire : ...., si non présente index renvoie -1

    Cordialement,

    Dan.
    1
    1. Salut,

      
          String string = "comment ça marche ?";
          String cherche = "marche";
          
          // recherche de la chaine "cherche" dans la chaine "string" :
      
      
           index = string.lastIndexOf(cherche);  // 11
      
          //  index renvoie la position de la chaine cherche dans la chaine string, si non présente index renvoie -1
      
      


      Cordialement,

      Necriptos
      2