public class Main {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
String[] a=new String[10000];
for(int i=1;i<=n+1;i++) {
a[i]=sc.nextLine();
}
System.out.println(a[1].length());
}
}
为什么输入int后第一个字符串不会被输入进去
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
// 吸收输入整数后留下的换行符
String temp = sc.nextLine();
String[] a=new String[10000];
for(int i=1;i<=n+1;i++) {
a[i]=sc.nextLine();
}
System.out.println(a[1].length());
}
}
如果对你有帮助,请点击采纳,能再来个关注就更nice了,感激不尽~~~下面链接有详细解释:
https://blog.csdn.net/qq_38367575/article/details/120420633