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
 
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).
 
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);
 
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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top