🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: aus.computers.java
2 messages
2 total messages Started by Luke Thu, 06 Apr 2000 00:00
from char[] to String
#867
Author: Luke
Date: Thu, 06 Apr 2000 00:00
20 lines
1067 bytes
Hi,

Can someone help me,

I have a char array that holds 50 chars.
I want to put the characters from the array in to a string.

Something like

<code>

for(i = 0; i < array.length; i++)
    String s.charAt(i) = array[i];

    System.out.println(s);

</code>

Does anyone know how to do this?
I'm sure there must be an easy way,
Re: from char[] to String
#868
Author: Benjamin Johnston
Date: Thu, 06 Apr 2000 00:00
28 lines
1255 bytes
> Hi,
>
> Can someone help me,
>
> I have a char array that holds 50 chars.
> I want to put the characters from the array in to a string.
>
> Something like
>
> <code>
>
> for(i = 0; i < array.length; i++)
>     String s.charAt(i) = array[i];
>
>     System.out.println(s);
>
> </code>
>
> Does anyone know how to do this?
> I'm sure there must be an easy way,

Take a look at java.lang.StringBuffer

There is also a String constructor that takes a char[],
ie. String s = new String(array);

-Benjamin Johnston
s355171@student.uq.edu.au
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads