java code point

Today saw the core technology Volume 1, find the code points of the word, it is really the first time to understand

Why did it get quasi-point code, which it acquired with quasi-point code string length and the direct use of length () to obtain, and some special characters may point code length is 2, but the length () to get really 1

This is how to explain it.

 

Research continues to be more

 

About string indexOf

  • public int indexOf (int ch):  index Returns the specified character string appears in the first, if no such character string, returns -1.

  • public int indexOf (int ch, int fromIndex):  return from the start position to find fromIndex index of the first occurrence of the specified character in the string, if no such character string, returns -1.

  • int indexOf (String str):  index Returns the specified character string appears in the first, if no such character string, returns -1.

  • int indexOf (String str, int fromIndex ):  return from fromIndex position to start looking at the index specified character first appeared in a string, if no such character string, or -1.

public class Main { public static void main(String args[]) {

String String = " aaa456ac " ; // Find the specified character is a subscript in the string. It returns a string where the subscripts; is not -1.

System . OUT . Println ( String . IndexOf ( " b " ) ) ; // indexOf (String str); return result: -1, "b" does not exist // future continues to look at the fourth character position start, include current position

System.out.println(string.indexOf("a",3));//indexOf(String str, int fromIndex); 返回结果:6

// (previous difference: The above parameters of type String, the following parameters of type int) Reference Data: A-97, B-98, C-99 @ from the beginning to find whether there is a specified character

The System . OUT . The println ( String . The indexOf ( 99 ) ) ; // the indexOf (int CH); return result:. 7 the System . OUT . The println ( String . The indexOf ( ' C ' ) ) ;

// indexOf (int ch); return result: 7 // Find ch from fromIndex, this is a character variable, not a string. A corresponding number of characters is 97.

System.out.println(string.indexOf(97,3));//indexOf(int ch, int fromIndex);

Return: 6 the System . OUT . The println ( String . The indexOf ( ' A ' , . 3 ) ) ; // the indexOf (CH int, int fromIndex); return: 6 } }

 

Guess you like

Origin www.cnblogs.com/ybbobo/p/11008166.html