Java String substring(int beginIndex, int endIndex)Example

Started by VelMurugan, Nov 28, 2008, 11:44 PM

Previous topic - Next topic

VelMurugan

Java String substring(int beginIndex, int endIndex)Example

String class substring(int beginIndex, int endIndex) method example

String class substring(int beginIndex, int endIndex)method example. This example  uses substring(int beginIndex, int endIndex)method &Returns a new string that is a substring of this string.

Here is the code

/**
* @(#) Substring1string.java
*Program that Returns a new string starting with the index specified and ending with the index specified that is a substring of this string.
* @Version  01-May-2008
* @author   Rose India Team
*/
public class Substring1string
{
    public static void main(String[] args)
    {
        String str = "RoseIndia is my Team.";
    //Returns a new string starting with 10 index and ending with 21 index of the above string declared above.
    System.out.println(str.substring(4,21));
  }
}


Source : CodeDiary