new String(char[] value) : String « java.lang « Java by API






new String(char[] value)

   
public class Main {
  public static void main(String args[]) {
    char charArray[] = { 'b', 'i', 'r', 't', 'h', ' ', 'd', 'a', 'y' };
    String s = new String("hello");

    // use String constructors
    String s1 = new String();
    String s2 = new String(s);
    String s3 = new String(charArray);
    String s4 = new String(charArray, 6, 3);

    System.out.printf("s1 = %s\ns2 = %s\ns3 = %s\ns4 = %s\n", s1, s2, s3, s4);
  }
}

   
    
    
  








Related examples in the same category

1.String.CASE_INSENSITIVE_ORDER
2.new String()
3.new String(byte[] bytes)
4.new String(byte[] ascii, int hibyte)
5.new String(byte[] bytes, int offset, int length)
6.new String(char[] value, int offset, int count)
7.new String(String original)
8.String: equals
9.String: compareTo(String stringValue)
10.== vs equals
11.String: charAt(int index)
12.String: copyValueOf(char[] data)
13.String: copyValueOf(char[] data, int offset, int count)
14.String: boolean endsWith(String suffix)
15.String: equalsIgnoreCase
16.String: byte[] getBytes()
17.String: getBytes(String charsetName)
18.String: getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
19.String: int hashCode()
20.String: indexOf(int intValue)
21.String: indexOf(String stringValue)
22.String: indexOf(int intValue, int fromIndex)
23.String: indexOf(String stringValue, int fromIndex)
24.String: lastIndexOf(int intValue)
25.String: lastIndexOf(int intValue, int fromIndex)
26.String: lastIndexOf(String stringValue)
27.String: lastIndexOf(String stringValue, int fromIndex)
28.String: int length()
29.String: matches(String regex)
30.String: boolean regionMatches(int toffset, String other, int ooffset, int len)
31.String: replace(char oldChar, char newChar)
32.String: split(String regex)
33.String: String[] split(String regex, int limit)
34.String: boolean startsWith(String prefix)
35.String: substring(int pos)
36.String: substring(int beginIndex, int endIndex)
37.String: trim()
38.String: char[] toCharArray()
39.String: toLowerCase()
40.Character: toLowerCase(char ch)
41.String: toUpperCase()
42.String: valueOf(boolean b)
43.String: valueOf(char c)
44.String: valueOf(char[] data)
45.String: valueOf(char[] data, int offset, int count)
46.String: valueOf(double d)
47.String: valueOf(float f)
48.String: valueOf(int i)
49.String: valueOf(long l)
50.String: valueOf(Object obj)