How do you insert one String into another in Java?
-
I know how to do it in Visual C# but I have to compare that language to Java, and I have absolutely no idea how to do it. Can you do it using Strings or do you have to use StringBuffers? Please let me know how to insert one String into another in Java, if there is a way to do so. Thanks in advance for all your answers. :)
-
Answer:
I'm not quite sure I understand, but I'll try. Putting one String into another isn't all that hard. Psuedocode below: String blah, wah; blah = ("Wahwahwah"); wah = blah; If you're asking about actually smooshing two different Strings together, it's not much harder. String blwhah = (blah + wah); I think that covers it. EDIT: Sent an email back to you, but here it is here. First, create a StringBuffer, that is: StringBuffer s1 = new StringBuffer("I am right now."); Then, use the insert method, that is: s1.insert(3, "happy "); Where 3 is the place the string will be put and "happy " (note the space) is the string to be added. Hope that helps.
promise at Yahoo! Answers Visit the source
Other answers
Use the string concat method to join the to strings, if that is what you mean. Other than that you could use the string buffers, but for something simple like this just use the string methods provided. Check http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html for the string methods
Nick P
Related Q & A:
- How to insert data from one table to another?Best solution by Stack Overflow
- How to see if one string contains another string?Best solution by Stack Overflow
- How do you attach one email to another in yahoo mail?Best solution by Yahoo! Answers
- How can I move bookmarks from one email to another one?Best solution by pcworld.com
- How do I suggest one of my friends in facebook to another one of my friends?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.