我是一个新的java程序员,在我下面的代码中,当我尝试输入像john smith这样的员工姓名时,只有john被输出打印出来。 如果我把使用扫描器类的输入
System.out.print("Enter Employee Name: ");
String employeeName = s.next();
上述
System.out.print("Enter SEX: ");
char SEX = s.next().charAt(0);
这段代码输出不是要求我employeename值。并直接打印剩余的值。
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
**package cs480;
import java.util.Scanner;
public class CS480D1_Richa_2_Week2 {
public static void main(String [] args){
Scanner s=new Scanner(System.in);
System.out.print("Ente Employee ID: ");
int employeeId = s.nextInt();
System.out.print("Ente SEX: ");
char SEX = s.next().charAt(0);
System.out.print("Ente Employee Name: ");
String employeeName = s.next();
System.out.println("Employee ID is " +employeeId);
System.out.println("Employee Name is " +employeeName);
System.out.println("Employee gender is " +SEX);
}
}**
检查右侧的'Related'部分的分隔符。你会得到你的答案 –