converting an array of char to string


T

Thanasis

hello to everyone,

does anyone know how could i convert an array of char to string.

thanks in advance
thanasis
 
Ad

Advertisements

S

Sudsy

Thanasis said:
hello to everyone,

does anyone know how could i convert an array of char to string.

thanks in advance
thanasis

String s = new String( char[] );

Ever try the javadocs? Really helpful!
 
T

Thanasis

Thanks a lot.
The constructor did work.
But i get trouble with the valueof method.
i declared a String text and an array of char as below:

String text;
char[] letter;
......
......
text=valueof(letter);

I ALWAYS GET A COMPILER ERROR FOR THE METHOD valueof(cannot resolve symbol).
 
Ad

Advertisements

R

Roedy Green

Ever try the javadocs? Really helpful!

It is not obvious to the newbie you have to look at both the target
and source classes, and that char[] is associated with Character. It
is also not obvious you need to scan the constructors too.

The fault lies with the Java class designers. The conversion methods
were named with the casual abandon of French irregular verbs
..
 
T

Tor Iver Wilhelmsen

Thanasis said:
text=valueof(letter);

I ALWAYS GET A COMPILER ERROR FOR THE METHOD valueof(cannot resolve symbol).

Do you intend to use the static method in String? You need the class
name:

test = String.valueOf(letter);
 
Ad

Advertisements

T

Thanasis

thanks a lot
? "Tor Iver Wilhelmsen said:
symbol).

Do you intend to use the static method in String? You need the class
name:

test = String.valueOf(letter);
 

Top