我得到的错误是
在变量' first'"处输入不匹配的内容。
首先是整数。请帮我弄清楚问题
import java.util.*;
public class Hello {
public static void main(String[] args) {
String ip,firstpart,lastpart;
int first,last,strlen,newvar;
Scanner scanner=new Scanner(System.in);
first=scanner.nextInt();
if(scanner.hasNextInt()){
last=scanner.nextInt();
}
else
last=0;
ip=scanner.nextLine();
firstpart=ip.substring(first);
strlen=firstpart.length();
newvar=strlen-last;
lastpart=firstpart.substring(0,newvar);
System.out.println(lastpart);
}
}
答案 0 :(得分:-1)
first=scanner.nextInt();
将以上代码替换为以下代码
first=Integer.parseInt(scanner.next());