Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to convert data in an array into a string
How to convert data in an array into a string
Java can use two methods to directly convert a character array into a string method 1: directly convert when constructing a string. char[] data = {'a ',' b ',' c ' }; String str = new string (data); Method 2: Call the method conversion of String class. String.valueOf(char[] ch)

Use the system;

Use the system. Assemble. Generics;

Use the system. Text;

Namespace Baidu. _008 1 105

{

Class plan

{

Static void Main(string[] args)

{

char[] a ={ '0 ',' 1 ',' 2 ',' 3 ' };

New arrangement (a). ToString();

}

}

Category arrangement

{

char[]a;

Public arrest (char[] a)

{

this.a = a

}

public new void ToString()

{

String s = string. Empty;

for(int I = 0; I<a. Length; i++)

{

s += a[i]。 ToString();

}

Console. Write a line;

}

}

}