目录

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

描述 (Description)

此方法将此字符串中的字符复制到目标字符数组中。

语法 (Syntax)

以下是此方法的语法 -

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

参数 (Parameters)

这是参数的细节 -

  • srcBegin - 要复制的字符串中第一个字符的索引。

  • srcEnd - 要复制的字符串中最后一个字符后的索引。

  • dst - 目标数组。

  • dstBegin - 目标数组中的起始偏移量。

返回值 (Return Value)

  • 它不返回任何值但抛出IndexOutOfBoundsException。

例子 (Example)

import java.io.*;
public class Test {
   public static void main(String args[]) {
      String Str1 = new String("Welcome to iowiki.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...");
      }
   }
}

这将产生以下结果 -

输出 (Output)

Copied Value = lcome t
↑回到顶部↑
WIKI教程 @2018