Thursday, 28 April 2016

Java Tutorial : Java StringBuilder [replace(int start,int end, String str) method]


Click here to watch in Youtube :
https://www.youtube.com/watch?v=b4qCUEj9EXY&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java StringBuilder [replace(int start,int end, String str) method]


StringBuilderDemo.java
/*
 * public StringBuilder replace(int start, int end,
 *                                         String str)
 *        
 * Parameters: 
 * -----------   
 * start - The beginning index, inclusive.
 * 
 * end - The ending index, exclusive.
 * 
 * str - String that will replace previous contents.
 * 
 * Returns: 
 * -------- 
 * This object.
 * 
 * Throws:
 * -------
 * StringIndexOutOfBoundsException - if start is negative, 
 * greater than length(), or greater than end. 
 */
public class StringBuilderDemo
{

    public static void main(String[] args)
    {
        StringBuilder sb = new StringBuilder("Hello Dave Welcome");
        System.out.println(sb);
        sb = sb.replace(6, 10, "Peter");
        System.out.println(sb);
    }
}
Output
Hello Dave Welcome
Hello Peter Welcome

Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/StringBuilderDemo_replace_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/StringBuilderDemo_replace_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/bb94d904a4b291ce0b8aeae9cc6d268e0b410985/BasicJava/StringBuilderDemo_replace_App/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment