copyValueOf(char[] data)
static String copyValueOf(char[] data)
- Returns a String that represents the character sequence in the array specified.
static String copyValueOf(char[] data, int offset, int count)
- Returns a String that represents the character sequence in the array specified.
public class Main {
public static void main(String[] argv) {
char[] chars = new char[] { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o','m' };
System.out.println(String.copyValueOf(chars));
}
}
The output:
java2s.com
copyValueOf(char[] data, int offset, int count)
public class Main {
public static void main(String[] arg) {
char[] textArray = { 'T', 'o', ' ', 'b', 'e', ' ', 'o', 'r', ' ', 'n', 'o', 't', ' ', 't', 'o',
' ', 'b', 'e' };
String text = String.copyValueOf(textArray, 9, 3);
System.out.println(text);
}
}
Home
Java Book
Essential Classes
Java Book
Essential Classes
String:
- String type and Literals
- String Concatenation
- String.CASE_INSENSITIVE_ORDER
- String Constructor
- charAt(int index):Get a single char by index
- String: compareTo(String stringValue)
- concat(String str)
- equals():Compare two string value for equality
- equals( ) vs ==
- contains(CharSequence s)
- copyValueOf(char[] data)
- endsWith(String suffix)
- format():Format a string
- getBytes():Get byte array from string
- getChars()
- indexOf
- intern a string
- isEmpty:if string is empty
- lastIndexOf()
- length() Returns the length of this string
- startsWith( )
- toLowerCase() and toUpperCase(): convert string case with locale
- substring:Get sub string from a string
- toCharArray():Get char array from string
- toString( )
- trim()
- valueOf():Convert boolean, char, double, float,int,long,object to String