Pages

Replace word in a sentence using java

************************************************
COMPLETE SOURCE CODE FOR : ReplaceAWordInASentence.java
************************************************


public class ReplaceAWordInASentence
{
public static void main(String[]args)
{
String a="Hello World";

//REPLACE Hello WITH Hi
String b=a.replaceAll("Hello","Hi");
a=b;
System.out.println(a);

//REPLACE World WITH Dude
b=a.replaceAll("World","Dude");
a=b;
System.out.println(a);
}
}


************************************************
JUST COMPILE AND EXECUTE IT
************************************************
Related Posts Plugin for WordPress, Blogger...