void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)

Java String类Java String类

getChars() 方法将字符从字符串复制到目标字符数组。

语法

public void getChars(int srcBegin, int srcEnd, char[] dst,  int dstBegin)
w)/3)/x)/u)/e.com提供本手册内容,请勿盗用!

参数

返回值

没有返回值,但会抛出 IndexOutOfBoundsException 异常。

实例

public class Test {
	public static void main(String args[]) {
		String Str1 = new String("www.w3xue.com");
		char[] Str2 = new char[6];

		try {
			Str1.getChars(4, 9, Str2, 0);
			System.out.print("拷贝的字符串为:" );
			System.out.println(Str2 );
		} catch( Exception ex) {
			System.out.println("触发异常...");
		}
	}
}
w)/3)/x)/u)/e.com提供本手册内容,请勿盗用!

以上程序执行结果为:

拷贝的字符串为:W3xue
w)/3)/x)/u)/e.com提供本手册内容,请勿盗用!

Java String类Java String类