This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
How to insert a substring into the string in Java? Like: String One = "My is Sabbir" String Two = "name"; So, after inserting "String Two" into "String One", the new "String One" will be -> "My name is Sabbir". Thanks.
First of all, those are string literals you're using. Secondly, even if you created an object using the String constructor, you cannot insert characters into a String object, you'd have to create a new String object. You can use the StringBuffer class however to insert characters or even another String into the StringBuffer object. Example:
The previous program will print "My name is Mike." and the original object was still used, only changed. Hope that's clear...