编写一个应用程序(java application),是该程序能从屏幕输入一个字符串和子字符串在该字符串的开始位置和长度,从而提出这个字符串的子串????
   求高手解决!!!!!
      不胜感激!!!!!!!!!!!

解决方案 »

  1.   

    import java.io.*;
    class Test
    {
    public static void main(String[] args) throws Exception
    {
    DataInputStream in=new DataInputStream(System.in);
    System.out.print("请输入字符串:");
    String line=in.readLine();
    int s,l;
    System.out.print("请输入子串的起始位置:");
    s=Integer.parseInt(in.readLine());
    System.out.print("请输入子串的长度:");
    l=Integer.parseInt(in.readLine());
    System.out.println("子串为:"+line.substring(s,l+s));
    }
    }
      

  2.   

    import java.io.* ;public class Test
    {
    public static void main( String args[] ) throws Exception
    {
    BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) ) ;
    System.out.println ("输入一个字符串") ;
    String s = in.readLine() ;
    System.out.println ("输入子串的起始位置") ;
    int start = new Integer( in.readLine().trim() ) ;
    System.out.println ("输入子串的长度") ;
    int length = new Integer( in.readLine().trim() ) ;

    String sub = s.substring( start-1, length+start-1 ) ;
    System.out.println ( "子串是" + sub ) ;
    }
    }这题似乎是简单了点