String str = "java search string";
int firstIndex = str.indexOf("java");
System.out.println("First occurrence of char "+
" is found at : " + firstIndex);
int lastIndex = str.lastIndexOf("java");
System.out.println("Last occurrence of char java is"+
" found at : " + lastIndex);
int first_in = str.indexOf("java", 10);
System.out.println("First occurrence of char java"+
" after index 10 : " + first_in);
int last_in = str.lastIndexOf("java", 20);
System.out.println("Last occurrence of char java " +
"after index 20 is : " + last_in);
}
}
Subscribe to:
Post Comments (Atom)
test your brain
https://www.youtube.com/watch?v=bEU9dkOG7co&feature=youtu.be
-
public class Strecke { Punkt p1, p2; Strecke (Punkt punkt1, Punkt punkt2) { this.p1 = punkt1; this.p2 = punkt2;...
-
public class Vowel { public static void main(String[] str) { String originalstring = "MOD...
-
final class DataSet { private final int x; private final int nextX; public DataSet(int x, int nextX) { this.x = ...
No comments:
Post a Comment