Monday 2 May 2016

Java Tutorial : Java StringBuilder [getChars method]


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

Click the below Image to Enlarge
Java Tutorial : Java StringBuilder [getChars method] 
StringBuilderDemo.java
/*
 * public void getChars(int srcBegin, int srcEnd, char[]
 *                                        dst, int dstBegin)
 * 
 * Parameters: 
 * ----------
 * srcBegin - start copying at this offset. 
 * 
 * srcEnd - stop copying at this offset.
 *  
 * dst - the array to copy the data into.
 *  
 * dstBegin - offset into dst.
 * 
 * Throws: 
 * -------
 * IndexOutOfBoundsException - if any of the following
 * is true: 
 * 
 * srcBegin is negative. 
 * dstBegin is negative.
 * the srcBegin argument is greater than the srcEnd
 * argument. 
 * srcEnd is greater than this.length().
 * dstBegin+srcEnd-srcBegin is greater than dst.length.
 */
public class StringBuilderDemo
{

    public static void main(String[] args)
    {

        String str = "Welcome to india peter";
        StringBuilder sb = new StringBuilder(str);
        System.out.println(sb);

        char[] charArray = new char[30];

        /*
         * copies characters from starting and ending index
         * into the destination character array
         */
        sb.getChars(11, 16, charArray, 0);

        System.out.println(charArray);
    }
}
Output
Welcome to india peter
india
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/StringBuilderDemo_getChars_App.zip?attredirects=0&d=1

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

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/bb94d904a4b291ce0b8aeae9cc6d268e0b410985/BasicJava/StringBuilderDemo_getChars_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