Java String Replace - Java Language Basics

Java examples for Language Basics:String

Description

Java String Replace

Demo Code


public class Main {
 
  public static void main(String args[]){
    String str="Replace Region";
   // w  w  w  .j  a v  a2  s.  c o  m
    System.out.println( str.replace( 'R','A' ) );
   
    System.out.println( str.replaceFirst("Re", "Ra") );
   
    System.out.println( str.replaceAll("Re", "Ra") );
 
  }
 
}

Result


Related Tutorials