所以我收集信息,即2个数字和一个字符串,稍后在我的代码中处理它们。数字工作正常,只要我能输出信输出用户输入的字母,一切都会正常工作。任何帮助非常感谢。为了清楚起见,当我说'不工作'时,我的意思是字母是空白的,最后一行代码输出:
这封信是
Scanner sc = new Scanner(System.in);
System.out.println("Enter two integers and a Letter ");
int num1 = sc.nextInt();
int num2 = sc.nextInt();
String s = sc.nextLine();
System.out.println("s is of type " + s.getClass().getName()); // s is a String
System.out.println(s); //s has value of this
char letter = s.charAt(0); //Why isn't this working?
System.out.println("The letter is " + letter); //letter isn't showing up