32060049 2015-12-08 06:32 采纳率: 94.4%
浏览 1634
已采纳

java利用String获取字符后输出

import java.util.Scanner;

public class Student {
public static void main(String[] args)
{
int i,j;
Scanner input = new Scanner(System.in);
System.out.print("please enter the number of students:");
int number = input.nextInt();
String name[] = new String[number];//学生姓名数组
System.out.print("please enter their name:");
for(i=0;i<number;i++){
name[i] = input.nextLine();
}
for(j=0;j<number;j++){
System.out.println("as follows:"+name[j]);
}

   }

}

运行后,输入数字2,但输入一次名字后程序就输出结果了,为啥

  • 写回答

3条回答 默认 最新

  • threenewbee 2015-12-08 06:39
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?