A schoolboy named ‘Jala kondapathi’ was living in a small village. But his full name is Jala
Kondapathi Rao in the registered certificates. He has joined the college after a school in a
city. His friends are called his name as “Jala Pathi Rao”. But he likes to call “Pathi”.
Write a java program to read name ‘Jala Kondapathi’ initially. Then modify the names as
per the sequence given above. Use StringBuffer Class methods to do changes in the name
public class Main
{
public static void main(String[] args) {
String name = "Jala kondapathi";
StringBuffer string =new StringBuffer(name);
int n = string.length();
string.replace(0,n,"Jala Pathi Rao");
System.out.println("Friends calls him \t"+string);
int final_n = string.length();
string.replace(0,n,"Pathi");
System.out.println("He likes to call \t"+string);
}
}
Go to https://onlinegdb.com/3E-7KS8jF to compile and run
Comments
Leave a comment