此方法将字符串中的字符复制到目标字符数组中。
public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
这是参数的详细信息-
srcBegin - 要复制的字符串中第一个字符的索引。
srcEnd - 要复制的字符串中最后一个字符之后的索引。
dst - 目标数组。
dstBegin - 目标数组中的起始偏移量。
import java.io.*; public class Test { public static void main(String args[]) { String Str1=new String("Welcome to Learnfk.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
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)