Phương thức getChars() của chuỗi Java
Ví dụ
Sao chép một phần của chuỗi vào mảng char
:
char[] myArray = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; System.out.println(myArray); String myStr = "Hello, World!"; myStr.getChars(7, 12, myArray, 4); System.out.println(myArray);
Định nghĩa và cách sử dụng
Phương thức getChars()
sao chép các ký tự từ một chuỗi sang một mảng char
.
Cú pháp
public void getChars(int start , int end , char[] destination , int position )
Giá trị tham số
Parameter | Description |
---|---|
start | Required. The position in the string of the first character to be copied. |
end | Required. The position in the string after the last character to be copied. |
destination | Required. The array to which the characters are copied. |
position | Required. The position in the destination array to which the copied characters are written. |
Chi tiết kỹ thuật
Trả về: | Không có |
---|---|
Ném: | IndexOutOfBoundsException - Trong bất kỳ điều kiện nào sau đây:
|
Phiên bản Java: | Bất kì |
❮ Các phương thức chuỗi