Thursday 10 March 2016

Java Tutorial : Java String (substring method)


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

Click the below Image to Enlarge
Java Tutorial : Java String (substring method) 
Java Tutorial : Java String (substring method) 
SubStringDemo1.java
/*
 * public String substring(int beginIndex, int
 *                                        endIndex)
 *
 * Parameters:
 * ---------- 
 * beginIndex - the beginning index, inclusive.
 * endIndex - the ending index, exclusive.
 *
 * Returns:
 * -------
 * Returns a string that is a substring of this
 * string. The substring begins at the specified
 * beginIndex and extends to the character at index
 * endIndex - 1. Thus the length of the substring is
 * endIndex-beginIndex.
 */

public class SubStringDemo1
{

    public static void main(String[] args)
    {
        String str = "Welcome";

        String subString = str.substring(3, 6);
        System.out.println("subString = " + subString);
    }
}
Output
subString = com
SubStringDemo2.java
/*
 * public String substring(int beginIndex)
 * 
 * Parameters: 
 * ----------
 * beginIndex - the beginning index,inclusive.
 * 
 * Returns: 
 * -------
 * Returns a string that is a substring of this
 * string. The substring begins with the character
 * at the specified index and extends to the end of
 * this string.
 */

public class SubStringDemo2
{

    public static void main(String[] args)
    {
        String str = "Welcome";

        String subString = str.substring(3);
        System.out.println("subString = " + subString);

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

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

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