import java.util.Scanner;
public class p78_8 {
public static void main(String[] args)
{
Scanner reader=new Scanner(System.in);
System.out.print("请输入一串字符:");
String str1=reader.next();
char []a=new char[100];
int n=0,len=0;
System.out.print("从第几个字符开始截取:");
n=reader.nextInt();
System.out.print("输入截取的长度:");
len=reader.nextInt();
int i=0;
char ch;
for(i=0;i<str1.length();i++)
{
if(i>=n &&i<str1.length())
{
ch=str1.charAt(i);
a[i]=ch;
}
}
for(i=n;i<len+n;i++)
{
System.out.print(a[i]);
}
reader.close();
}
}
运行结果: