我有这样的代码:扫描仪无法操作
byte[] nombre = new byte[20];
System.out.print("Cuenta a modificar: ");
cuenta = s.nextInt();
boolean existe = estaRepetido(cuenta);
if (existe == false){
System.out.println("La cuenta no existe");
}
else {
String nomCliente;
System.out.print("Nombre: ");
nomCliente = s.nextLine();
System.out.print("Cantidad: ");
double cantidad = Double.parseDouble(s.nextLine());
for(int i = 0; i < 20 && i < nomCliente.getBytes().length; i++){
nombre[i] = nomCliente.getBytes()[i];
}
String nomModificar = new String (nombre);
modificar(cuenta, nomModificar, cantidad);
}
但是当在终端上以某种方式运行它海外nomCliente = s.nextLine();以类似的方式结束:
Cuenta a modificar: 0
Nombre: Cantidad: 0
有什么想法吗?这只是一个非常大的方法的一部分,但这是造成麻烦的唯一扫描仪。
我认为这可能是由于您使用nextInt()而不是nextLine()为“CUENTA”。 – 2013-03-25 22:35:54