3:48 am - Monday June 25, 2018

StringBuilder Example Program for replace(int start,int end,String str)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
@Author: Candidjava.com
@Description:source code to replace a particular character in a string with another character
*/
import java.io.*;
import java.lang.String;
public class Sreplace
{
public static void main(String[] args)throws IOException
{
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the string");
String str1=bf.readLine();
String s=str1.replace("j","b");
 // replaces the letter "J" in the string with letter "b"
System.out.println(s);
}
}

Output:
enter the string:
java
bava

BACK

Filed in: Z-A All Java Codes

Comments are closed.