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
热门推荐
10 香港老妈结婚祝福语简短
11 毕业立体贺卡祝福语简短
12 简短新年年会祝福语
13 评论小品祝福语大全简短
14 恭喜师兄结婚祝福语简短
15 员工集体辞职祝福语简短
16 高中新生祝福语 简短
17 装修祝福语男生搞笑简短
18 生日开业蛋糕祝福语简短