- Java.lang - Home
- Java.lang - Boolean
- Java.lang - Byte
- Java.lang - Character
- Java.lang - Character.Subset
- Java.lang - Character.UnicodeBlock
- Java.lang - Class
- Java.lang - ClassLoader
- Java.lang - Compiler
- Java.lang - Double
- Java.lang - Enum
- Java.lang - Float
- Java.lang - InheritableThreadLocal
- Java.lang - Integer
- Java.lang - Long
- Java.lang - Math
- Java.lang - Number
- Java.lang - Object
- Java.lang - Package
- Java.lang - Process
- Java.lang - ProcessBuilder
- Java.lang - Runtime
- Java.lang - RuntimePermission
- Java.lang - SecurityManager
- Java.lang - Short
- Java.lang - StackTraceElement
- Java.lang - StrictMath
- Java.lang - String
- Java.lang - StringBuffer
- Java.lang - StringBuilder
- Java.lang - System
- Java.lang - Thread
- Java.lang - ThreadGroup
- Java.lang - ThreadLocal
- Java.lang - Throwable
- Java.lang - Void
- Java.lang Package Useful Resources
- Java.lang - Useful Resources
- Java.lang - Discussion
Java.lang.String.copyValueOf() Method
Description
The java.lang.String.copyValueOf(char[] data, int offset, int count) method returns a String that represents the character sequence in the array specified.
Declaration
Following is the declaration for java.lang.String.copyValueOf() method
public static String copyValueOf(char[] data, int offset, int count)
Parameters
data − This is the character array.
offset − This is the initial offset of the subarray.
count − This is the length of the subarray.
Return Value
This method returns a String that represents the character sequence in the array specified.
Exception
NA
Example
The following example shows the usage of java.lang.String.copyValueOf() method.
package com.tutorialspoint;
import java.lang.*;
public class StringDemo {
public static void main(String[] args) {
// character array
char[] charArr = { 'C', 'O', 'M', 'P', 'I', 'L', 'E', ' ',
'O', 'N', 'L', 'I', 'N', 'E' };
/* returns a String that contains the characters of the character
array with offset as 8 and length as 6 */
String str = String.copyValueOf(charArr, 8, 6 );
// prints the substring with length as 6
System.out.println(str);
}
}
Let us compile and run the above program, this will produce the following result −
ONLINE
java_lang_string.htm
Advertisements