java commonly used class -String

1.string.indexOf(str);

  Find the index specified string in string of the first occurrence. Return -1 not found.

String str1="012345";
String str2="23";
System.out.println( str1.indexOf(str2) );//2

2.string。indexOf(string str,int index);

  Starts at index index position, find the index position in the string str in.

String str1="012345012345";
String str2="23";
System.out.println( str1.indexOf(str2,5) );//8

Guess you like

Origin www.cnblogs.com/leizz/p/11563343.html