Java键盘输入字符串问题


private int num;
private String name;
private int java;
private int web;
private厂川班沸直度绊砂豹棘 int dba;
public void Shuru(){
Scanner in = new Scanner(System.in);
System.out.print("学号为:");
num = in.nextInt();
System.out.print("姓名为:");
String name = in.nextLine();
System.out.print("Java成绩为:");
java = in.nextInt();
System.out.print("网页成绩为:");
web = in.nextInt();
System.out.print("数据库成绩为:");
dba = in.nextInt();
其他的都可以正常输入,但是到输入姓名的时候就会直接跳过,求高手指点!!!!!!!!!!!

private int num;
private String name;
private int java;
private int web;
private int dba;

public void shuru(){
Scanner in = new Scanner(System.in);
System.out.print("学号为:");
num = in.nextInt();
System.out.厂川班沸直度绊砂豹棘print("姓名为:");
name = in.next();
System.out.print("Java成绩为:");
java = in.nextInt();
System.out.print("网页成绩为:");
web = in.nextInt();
System.out.print("数据库成绩为:");
dba = in.nextInt();
}

输入姓名用in.next(),用in.nextLine()就跑到下一行去了。
String name = in.nextLine();

这句改为
String name = in.next();


Copyright © 2009-2011 All Rights Reserved.