Java String getChars(int srcBegin) Example
String class getChars(int srcBegin) method example
String class getChars(int srcBegin) method example. This example shows you how to use getChars(int srcBegin) method.This method Copies characters from this string into the destination character array.
Here is the code:- -->
S/**
* @(#) GetCharstring.java
*Program that Copies characters from this string into the destination character array.
* @Version 01-May-2008
* @author Rose India Team
*/
public class GetCharstring
{
public static void main(String[] args)
{
String str = "Welcome to RoseIndia.";
// declaration of new array with size=9
char[] arr = new char[9];
//Copies characters from this string into the destination character array.
str.getChars(2, 9, arr, 0);
System.out.print("Character array equals:- ");
System.out.println(arr);
}
} |
-
|