Java String copyValueOfchar[] Example
String class copyValueOfchar[] method example
String class copyValueOf char[] method example. This example shows you how to use copyValueOf char[] method.This method Returns a String that represents the character sequence in the array specified.
Here is the code:-
/**
* @(#) CopyValueOf.java
*Program that Returns a String that is equivalent to the specified character array.
* @Version 01-May-2008
* @author Rose India Team
*/
public class CopyValueOf
{
public static void main(String[] args)
{
// declare a character array with data.
char[] arr = new char[] { 'r', 'o', 's', 'e','i','n','d','i','a' };
// Create a String containig the contents of array starting at index 1 for length 2.
String str = String.copyValueOf(arr, 0, 4);
// Display the results of the new String.
System.out.println("The new Copied String is:-" + str);
}
} |
null
|