getchars() Intercept multiple characters and receive them by other strings
String a = "Hello Word";
char[] b = new char[10];
a.getChars(0, 5, b, 0);
System.out.println(b);
- 1
- 2
- 3
- 4
The output result is Hello, where the first parameter 0 is the initial subscript of the string to be intercepted (int sourceStart), the second parameter 5 is the next subscript after the end of the string to be intercepted (int sourceEnd) that is, the actual subscript is int sourceEnd-1, the third parameter is the received string (char target[]), and the last parameter is the position where the received string starts to receive.