Usage of substring () and indexof () in "Javase" Java
/** * @ details about the use of substring () and indexof (), how to combine * @author Night Legends * */public Class test {public static void main (String[] args) {String str = "My name is xiaoye ' S chuanshou"; str = str.substring (6);// Str=str.substring (Int beginindex); intercepts the string of length beginindex from the first letter of STR and assigns the remaining string to Str;system.out.println (str) ; str = str.substring (2, 10);// intercepts the string from Beginindex to Endindex at the end of STR and assigns it to STR; The value that contains the Beginindex location, but does not contain the value of Endindex) System.out.println (str); string sr = "My name is xiaoye ' S chuanshou"; string sx = "is"; Int index = sr.indexof (SX);// If present, returns the index position System.out.println (index+ "<<<<") where the string begins to appear; Int index2 = sr.indexof (SX, &NBSP;3);//This means starting at index position 3, looking for a string sx= "is", and then returning the index position where the string starts to appear System.out.println (index2+ "<<<<<"); String str2= "<12453>123"; SyStem.out.println (Str2.indexof ("wwww"));//If it does not contain a string wwww, then it is proved that there is no location in the entire index, returning to the Guardian -1system.out.println (Str2.substring ( Str2.indexof ("123") +1,9) + "<<<<<<");//The above code, first Str2.index ("123") returned is 7, representing the beginning of the 7th bit to appear the entire string//plus 1, The meaning of the representation is that the index position 8//from index position 8 to 9, because substring is not the end of the head, so substring (8,9) takes out 2}.
This article from "Promise always attached to the small wood 、、、" blog, please be sure to keep this source http://1936625305.blog.51cto.com/6410597/1556999
Usage of substring () and indexof () in Java