Java Programming Example of how to extract substring from the string?

This program accepts the string, starting index and ending index from the keyboard and extract the substring from the given string according to index.

import java.io.*;

/**
 *
 * @author JavaHotSpot
 */

public class substring
{
  public static void main(String args[])
 {

     String s1,s2,s3,s4;
     int st,ed;
     DataInputStream d;
     try
     {
     System.out.println("Enter the String");
     d=new DataInputStream(System.in);
     s1=(String)d.readLine();
     System.out.println("Enter the Starting Index");
     s2=(String)d.readLine();
     st=Integer.parseInt(s2);
     System.out.println("Enter the Ending Index");
     s3=(String)d.readLine();
      ed=Integer.parseInt(s3);
      s4=s1.substring(st, ed);
     System.out.println("String is = "+s1+" Substring is ="+s4);
     }
     catch(Exception e)
     {
         System.out.println(e.toString());
     }
 }
}

Output:
Enter the String
JavaHotSpot
Enter the Starting Index
3
Enter the Ending Index
8