代码如下,为什么
static class Bomblet extends Telephone{ //小灵通类
String[] record; //通讯录记录
double receivedTime; //被叫时间
Bomblet(String b, String n){
super(b, n);
}
double getReceivedTime( ) { return receivedTime; }
void setReceivedTime(double d) {
receivedTime = d; //设置被叫时间
}
void builtNumberBook(){ //建立简单通讯录
int sum;
// String s = "";
Scanner read = new Scanner(System.in);
System.out.print("请输入您要建立的通讯录记录条数:");
sum = read.nextInt();
record = new String[sum];
System.out.print("请输入您要建立的"+sum+"条通讯录记录");
System.out.println("(请以“姓名+空格+号码”的格式输入,每条记录以回车结束):");
**********************************************************
//为什么sum = 3 时,只循环2次
for(int i = 0; i < record.length; i++){
record[i] = read.nextLine();
}
**************************************************************
System.out.print(record.length);
System.out.print("您已成功建立"+sum+"条通讯录记录,你可以调用相应函数查询通讯录!");
}
结果图: