The Artima Developer Community
Sponsored Link

Java Answers Forum
substrings

1 reply on 1 page. Most recent reply: Oct 20, 2003 12:22 AM by Senthoorkumaran Punniamoorthy

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
James

Posts: 1
Nickname: louie666
Registered: Oct, 2003

substrings Posted: Oct 19, 2003 10:27 PM
Reply to this message Reply
Advertisement
I am trying to figure out a way to insert a second string into a first string to make a new string. I'm trying to figure out how to utilize the substrings with a position integer so that my input will apply.


Senthoorkumaran Punniamoorthy

Posts: 335
Nickname: senthoor
Registered: Mar, 2002

Re: substrings Posted: Oct 20, 2003 12:22 AM
Reply to this message Reply
if the length of the String is 20 and if you want to insert after 10th position

You have to take a subsstring from start {0} to the point{10} where you want to insert the new string and store in a variable. The from 11 to 20 subsstring and keep it in another variable and then add the three string together where your string which needs to be inserted is in the middle. Or use StringBuffer to do the concatenation.

String are immutable so you can insert something in the middle of already existing string with out creating a new String.

I might have made a mistake with the indexes please reffer the Java Doc for Strings on substring. I am not sure the indexes are inclusive or exclusive

Flat View: This topic has 1 reply on 1 page
Topic: merging two sorted arrays into a thrid one Previous Topic   Next Topic Topic: sevlets

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use