public int cut(int b){
String str1;
b = 0;
Scanner str = new Scanner(System.in);
System.out.println("Write your string: ");
str1 = str.next();
Scanner in = new Scanner (System.in);
System.out.println("Write a number: ");
int num1 = in.nextInt();
System.out.println("Write another number: ");
int num2 = in.nextInt();
System.out.println(str1.substring(num1, num2));
return b;
}
到目前为止,这是我的代码。我希望用户编写一个字符串并从他想要剪切他刚输入的字符串的位置写入。我无法得到的部分是获取该子字符串。