🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: aus.computers.java
Article #868

Re: from char[] to String

#868
From: 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
Technical Details
Message-ID: <8ci0ha$sjj$1@bunyip.cc.uq.edu.au>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <0yYG4.63874$3b6.245144@ozemail.com.au>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d6db,b0622beecc4534e1
X-Google-Attributes: gid10d6db,public
From: "Benjamin Johnston" <s355171@student.uq.edu.au>
Subject: Re: from char[] to String
Date: 2000/04/06
Message-ID: <8ci0ha$sjj$1@bunyip.cc.uq.edu.au>
X-Deja-AN: 607524072
References: <0yYG4.63874$3b6.245144@ozemail.com.au>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
X-Complaints-To: news@uq.edu.au
X-Trace: bunyip.cc.uq.edu.au 955024746 29299 172.20.15.103 (6 Apr 2000 12:39:06 GMT)
Organization: University of Queensland
X-MSMail-Priority: Normal
NNTP-Posting-Date: 6 Apr 2000 12:39:06 GMT
Newsgroups: aus.computers.java