Java String replace * with ^

Description

Java String replace * with ^

public class Main {
  public static void main(String[] args) {
    String firstString = "This sentence ends in 5 stars *****";
     /*from  w ww.  ja  va2  s.c om*/
    System.out.printf("Original String 1: %s\n", firstString);

    // replace '*' with '^'
    firstString = firstString.replaceAll("\\*", "^");

  }
}



PreviousNext

Related