Development Java Tutorial

public class MainClass
{
   public static void main( String args[] )
   {
      String firstString = "This sentence ends in 5 stars *****";
         
      System.out.printf( "Original String 1: %s\n", firstString );
      // replace 'stars' with 'carets'
      firstString = firstString.replaceAll( "stars", "carets" );
      System.out.printf(
         "\"carets\" substituted for \"stars\": %s\n", firstString );
   }
}
Original String 1: This sentence ends in 5 stars *****
"carets" substituted for "stars": This sentence ends in 5 carets *****