Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String replace

 
Chandra S Marappa
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to replace one string with another string
 
Jan Groth
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi chandar,

in order to help you we need more details. You might also want to study the String API, there are loads of methods, most of them quite self explaining by their name & parameter list...

Greets,
Jan
 
Naren Chivukula
Ranch Hand
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Originally posted by Chandra Shekar marappa
How to replace one string with another string


String literals can't be changed once created. If you mean to ask about replacement of string variables, simple overwrite the existing string variable with new string reference

Regards,
Narendranath
 
Hentay Duke
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First you must understand how Strings are immutable. Then you describe exactly what you want. But a simplistic answer would be.

String string1 = "String 1";
String string2 = "String 2";
string1 = string2;


But be warned you must grasp the immutable quality of Strings, because this may not be doing what you expect it to do.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic