欢迎您 本站地址:  
返回首页   返回编程教学   警世通言  推箱子  名人励志书籍  各国区号代码  中国各省市区简称  史记  金史  FC小霸王 

Java getChars() 方法

Java String类Java String类


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

语法

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

参数

返回值

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

实例

public class Test {
    public static void main(String args[]) {
        String Str1 = new String("www.www.fxku.cn");
        char[] Str2 = new char[6];
        try {
            Str1.getChars(4, 10, Str2, 0);
            System.out.print("拷贝的字符串为:" );
            System.out.println(Str2 );
        } catch( Exception ex) {
            System.out.println("触发异常...");
        }
    }
}

以上程序执行结果为:

拷贝的字符串为:runoob

Java String类Java String类

小库提示

扫描下方二维码,访问手机版。