Java String get sub string

Description

Java String get sub string


// String class substring methods.

public class Main 
{
   public static void main(String[] args)
   {/*from   ww  w  .  j a v  a  2  s  . c o m*/
      String letters = "abcdefghijklmabcdefghijklm";

      // test substring methods
      System.out.printf("Substring from index 20 to end is \"%s\"\n",
         letters.substring(20));
      System.out.printf("%s \"%s\"\n", 
         "Substring from index 3 up to, but not including 6 is",
         letters.substring(3, 6));
   } 
}



PreviousNext

Related