我在返回用户输入字符串时遇到了困难。如果我有代码:
System.out.println("please enter a digit: ");
number1 = in.nextInt();
System.out.println("enter another digit: ");
number2 = in.nextInt();
System.out.println("enter a string: ");
string = in.nextLine();
//calculations
System.out.println(number1);
System.out.println(number2);
System.out.println(string);
它打印出数字而不是字符串。我觉得解决方案很简单,但我现在脑子里放了个屁。任何帮助,将不胜感激!