Java String copyValueOf Example
String class copyValueOf method example
String class copyValueOf method example. This example shows you how to use copyValueOf method.This method Returns a String that represents the character sequence in the array specified.
Syntax:-copyValueOf(char[] data)
Here is the code:-
/**
* @(#) CopyValueOf1.java
*Program that Returns a String that is equivalent to the specified character array.
* @Version 01-May-2008
* @author Rose India Team
*/
public class CopyValueOf1
{
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' };
// Returns a String that is equivalent to the specified character array.
String str = String.copyValueOf(arr);
// Display the results of the new String.
System.out.println("The new Copied String is:-" + str);
}
} |
-
|