🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #425

Re: copy string to string

#425
From: Lori M Olson [TeamB]
Date: Tue, 16 Aug 2005 18:13
41 lines
2160 bytes
apostolish wrote:
> Hello, my problem is:
> 
> 
> String str1 = new String("                    ");          // length 20
> String str2 = new String("test");                        // length 4
> 
> Which is the  fastest  way to copy str2 to str1 from postion 10 ?
> (for example: str1 = "         test       ")
> 
> Thanks in advance,
> Apostolis
> Hatziyannis
> 
> 

Just to be completely clear... Strings are immutable, so what you are 
attempting to do is not altering str1, but creating a new String (which 
can be assigned to str1 if you want) with the desired contents.

Look at the API for String, and for StringBuffer.  If you are using JDK 
5, then also look at StringBuilder.

-- 

Regards,

Lori Olson [TeamB]

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
     http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
     http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
     http://www.visi.com/~gyles19/fom-serve/cache/1.html
Technical Details
Message-ID: <43022ca5$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newshub.sdsu.edu!cyclone.bc.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.spamkiller.net!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <4301e319@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,1e2a9eb6cc0247cb
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 16 Aug 2005 12:13:25 -0600
From: "Lori M Olson [TeamB]" <javadragon@techie.com>
User-Agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: copy string to string
References: <4301e319@newsgroups.borland.com>
In-Reply-To: <4301e319@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 142.179.181.200
Message-ID: <43022ca5$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1124215973 142.179.181.200 (16 Aug 2005 11:12:53 -0700)
Lines: 41
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newshub.sdsu.edu!cyclone.bc.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.spamkiller.net!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail