J'utilise indexof()
pour trouver une sous-chaîne. Il trouve ma chaîne si ma chaîne n'est pas en première position, si ma chaîne est à la première position, cela ne fonctionnera pas. Quelqu'un peut-il suggérer une autre façon de le trouver?Comment utiliser la méthode Indexof() dans Java
Voici mon code: -
public class IndexOfStr {
public static void main(String args[]) {
String s = "Niraj";
System.out.println(s);
System.out.println("indexOf(niraj, 1) -> " + s.indexOf("niraj", 1));
}}
Sortie: -
Niraj indexOf(niraj, 1) -> -1
Je suis en train de trouver la chaîne dans mon fichier Excel.
s.indexOf ("Niraj") Merci –