Java String getChars()方法示例。
String类的getChars()方法接受四个参数,即-
srcBegin-要复制的字符串中第一个字符的索引。
srcEnd-要复制的字符串中最后一个字符之后的索引。
dst-目标数组。
dstBegin-目标数组中的起始偏移量。
示例
它将当前字符串的所有字符复制到目标字符数组。
import java.io.*;
public class Test {
public static void main(String args[]) {
String Str1 = new String("Welcome to Nhooo.com");
char[] Str2 = new char[7];
try {
Str1.getChars(2, 9, Str2, 0);
System.out.print("Copied Value = " );
System.out.println(Str2 );
} catch ( Exception ex) {
System.out.println("Raised exception...");
}
}
}输出结果
Copied Value = lcome t
热门推荐
1 训练狗狗基础
2 怎么训练狗狗笑
3 怎么训练狗狗卧下
4 上海狗狗训练基地
5 训练狗狗排便
6 狗狗基础训练
8 如何训练狗狗装死
9 狗狗站姿训练
10 狗狗训练用品
11 训练狗狗吧
12 狗狗要怎么训练
13 怎么训练狗狗玩球
14 训练狗狗唤回
15 狗狗训练躺下
16 狗狗训练指令
17 狗狗的训练技巧
18 狗狗不好训练