Wrox Programmer Forums
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 11th, 2010, 01:36 PM
Registered User
 
Join Date: Mar 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Red face String Handling

Suppose there is a String.
Say, String test="My name is debasish";
Now I want to edit any one character.
Say, I want to edit the seventh character, e to c.
How can I achieve this?
One method is to change the string to an character array.
But I want to know if there is any other way to achieve this...
 
Old March 11th, 2010, 04:39 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Code:
String test="My name is debasish";

test = test.substring(0,6) + "c" + test.substring(7);
 
Old March 11th, 2010, 09:21 PM
Friend of Wrox
 
Join Date: Dec 2008
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
Default String.format

If you are using java 1.5 or later, go with String.format. String concatenation costs more memory.
 
Old June 26th, 2010, 10:20 PM
Registered User
 
Join Date: Jun 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up Thanks

Thanks for posting this, I have taken JAVA, and I'm always looking for valid information such as this.





Similar Threads
Thread Thread Starter Forum Replies Last Post
RegEx to match a string only if it does'nt have a particular string within it arshsidhu BOOK: Beginning Regular Expressions 1 January 27th, 2009 05:17 PM
Casting String array to string Samatha ASP.NET 1.0 and 1.1 Professional 1 December 5th, 2006 07:46 AM
how to replace a string with another string/number crmpicco Javascript How-To 4 March 14th, 2005 12:59 PM
PHP String handling Proglem ghalebro PHP How-To 1 August 19th, 2004 08:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.