The java.lang.String.copyValueOf(char[] data, int offset, int count) method returns a String that represents the character sequence in the array specified.
DeclarationFollowing 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.
This method returns a String that represents the character sequence in the array specified.
ExceptionNA
ExampleThe 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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4